tools/log: accept only a single string
This tool is only meant for testing purposes and it's far simpler to only support a single string commandline argument.
This commit is contained in:
parent
3feca52a87
commit
2f2dfd1423
@ -15,28 +15,23 @@
|
|||||||
enum {
|
enum {
|
||||||
ARG_SELF,
|
ARG_SELF,
|
||||||
ARG_LEVEL,
|
ARG_LEVEL,
|
||||||
ARG_FORMAT,
|
ARG_VALUE,
|
||||||
|
|
||||||
MIN_ARGS,
|
NUM_ARGS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int main (int const argc, char const **argv)
|
int main (int const argc, char const **argv)
|
||||||
{
|
{
|
||||||
if (argc < MIN_ARGS) {
|
if (argc < NUM_ARGS) {
|
||||||
std::cerr << "usage: " << argv[ARG_SELF] << " <level> <format> [arg]...\n";
|
fmt::print (stderr, "usage {} <level> <string>\n", argv[ARG_SELF]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const level = cruft::log::to_level (argv[ARG_LEVEL]);
|
auto const level = cruft::log::to_level (argv[ARG_LEVEL]);
|
||||||
auto const format = argv[ARG_FORMAT];
|
auto const value = argv[ARG_VALUE];
|
||||||
|
|
||||||
auto const count = argc - 3;
|
cruft::log::write (level, "{}", value);
|
||||||
switch (count) {
|
|
||||||
case 0: cruft::log::write (level, format); break;
|
|
||||||
case 1: cruft::log::write (level, std::string_view{format}, argv[MIN_ARGS + 0]); break;
|
|
||||||
case 2: cruft::log::write (level, std::string_view{format}, argv[MIN_ARGS + 0], argv[MIN_ARGS + 1]); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user