-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:add color and ttl check #199
base: main
Are you sure you want to change the base?
Changes from all commits
0b07f2e
e535cc7
d53e704
9de1e58
5f1deb1
ae3736f
177db63
64af3f0
c98788b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,17 @@ | |
#include "command.h" | ||
#include "configure.h" | ||
|
||
#ifdef _WIN32 | ||
#include <io.h> | ||
#define isatty _isatty | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary blank line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright 👍 i will remove it. |
||
#define fileno _fileno | ||
#else | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary blank line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright i will also remove it. |
||
#include <unistd.h> | ||
#endif | ||
#include <termcolor/termcolor.hpp> | ||
|
||
constexpr std::string_view USAGE_DETAILS{R"EOF( | ||
Global Options: | ||
|
||
|
@@ -88,6 +99,13 @@ For more documentation, visit https://github.com/sourcemeta/jsonschema | |
|
||
auto jsonschema_main(const std::string &program, const std::string &command, | ||
const std::span<const std::string> &arguments) -> int { | ||
bool use_colors = true; | ||
if (std::find(arguments.begin(), arguments.end(), "--no-color") != | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have a Also, you probably want to support a short version of this. Maybe Finally, you should document this new option on the help page and on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright ,i am getting really exited. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, just to keep things simpler and merge this sooner, let's avoid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not feeling good,i think my health is not good.I am going home i will work on this in few days. Thanks. |
||
arguments.end()) { | ||
use_colors = false; | ||
} else if (!isatty(fileno(stdout))) { | ||
use_colors = false; | ||
} | ||
if (command == "fmt") { | ||
return sourcemeta::jsonschema::cli::fmt(arguments); | ||
} else if (command == "frame") { | ||
|
@@ -117,7 +135,12 @@ auto jsonschema_main(const std::string &program, const std::string &command, | |
<< sourcemeta::jsonschema::cli::PROJECT_VERSION << "\n"; | ||
std::cout << "Usage: " << std::filesystem::path{program}.filename().string() | ||
<< " <command> [arguments...]\n"; | ||
std::cout << USAGE_DETAILS; | ||
if (use_colors) { | ||
std::cout << termcolor::yellow << USAGE_DETAILS << termcolor::reset | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it makes much sense to color out the entire help. Maybe just color out the project name in line 134? |
||
<< "\n"; | ||
} else { | ||
std::cout << USAGE_DETAILS << "\n"; | ||
} | ||
return EXIT_SUCCESS; | ||
} | ||
} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you mask all unnecessary files (except |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
termcolor
is a CMake project with its ownCMakeLists.txt
, so instead of including its files directly here (which is not a best practice), you should create acmake/FindTermColor.cmake
and them here dofind_package(TermColor REQUIRED)
like we do for other dependenciesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright @jviotti got your point.