Rename example/jsonptr's -compact flag

This commit is contained in:
Nigel Tao committed 2020-03-12 16:52:26 +11:00
1 parent a3827275c0
commit 3690e83d86
1 file changed
+8 -8
+8 -8
View File
@@ -117,7 +117,7 @@ static const char* usage =
"Usage: jsonptr -flags input.json\n" "Usage: jsonptr -flags input.json\n"
"\n" "\n"
"Flags:\n" "Flags:\n"
" -c -compact\n" " -c -compact-output\n"
" -i=NUM -indent=NUM\n" " -i=NUM -indent=NUM\n"
" -o=NUM -max-output-depth=NUM\n" " -o=NUM -max-output-depth=NUM\n"
" -q=STR -query=STR\n" " -q=STR -query=STR\n"
@@ -138,7 +138,7 @@ static const char* usage =
"duplicate keys. Canonicalization does not imply Unicode normalization.\n" "duplicate keys. Canonicalization does not imply Unicode normalization.\n"
"\n" "\n"
"Formatted means that arrays' and objects' elements are indented, each\n" "Formatted means that arrays' and objects' elements are indented, each\n"
"on its own line. Configure this with the -c / -compact, -i=NUM /\n" "on its own line. Configure this with the -c / -compact-output, -i=NUM /\n"
"-indent=NUM (for NUM ranging from 0 to 8) and -t / -tabs flags.\n" "-indent=NUM (for NUM ranging from 0 to 8) and -t / -tabs flags.\n"
"\n" "\n"
"----\n" "----\n"
@@ -511,7 +511,7 @@ struct {
int remaining_argc; int remaining_argc;
char** remaining_argv; char** remaining_argv;
bool compact; bool compact_output;
bool fail_if_unsandboxed; bool fail_if_unsandboxed;
size_t indent; size_t indent;
uint32_t max_output_depth; uint32_t max_output_depth;
@@ -545,8 +545,8 @@ parse_flags(int argc, char** argv) {
} }
} }
if (!strcmp(arg, "c") || !strcmp(arg, "compact")) { if (!strcmp(arg, "c") || !strcmp(arg, "compact-output")) {
flags.compact = true; flags.compact_output = true;
continue; continue;
} }
if (!strcmp(arg, "fail-if-unsandboxed")) { if (!strcmp(arg, "fail-if-unsandboxed")) {
@@ -812,7 +812,7 @@ handle_token(wuffs_base__token t) {
} else { } else {
// Write preceding whitespace. // Write preceding whitespace.
if ((ctx != context::in_list_after_bracket) && if ((ctx != context::in_list_after_bracket) &&
(ctx != context::in_dict_after_brace) && !flags.compact) { (ctx != context::in_dict_after_brace) && !flags.compact_output) {
TRY(write_dst("\n", 1)); TRY(write_dst("\n", 1));
for (uint32_t i = 0; i < depth; i++) { for (uint32_t i = 0; i < depth; i++) {
TRY(write_dst(flags.tabs ? INDENT_TAB_STRING : INDENT_SPACES_STRING, TRY(write_dst(flags.tabs ? INDENT_TAB_STRING : INDENT_SPACES_STRING,
@@ -835,13 +835,13 @@ handle_token(wuffs_base__token t) {
// continuation of a multi-token chain. // continuation of a multi-token chain.
if (!t.link_prev()) { if (!t.link_prev()) {
if (ctx == context::in_dict_after_key) { if (ctx == context::in_dict_after_key) {
TRY(write_dst(": ", flags.compact ? 1 : 2)); TRY(write_dst(": ", flags.compact_output ? 1 : 2));
} else if (ctx != context::none) { } else if (ctx != context::none) {
if ((ctx != context::in_list_after_bracket) && if ((ctx != context::in_list_after_bracket) &&
(ctx != context::in_dict_after_brace)) { (ctx != context::in_dict_after_brace)) {
TRY(write_dst(",", 1)); TRY(write_dst(",", 1));
} }
if (!flags.compact) { if (!flags.compact_output) {
TRY(write_dst("\n", 1)); TRY(write_dst("\n", 1));
for (size_t i = 0; i < depth; i++) { for (size_t i = 0; i < depth; i++) {
TRY(write_dst(flags.tabs ? INDENT_TAB_STRING : INDENT_SPACES_STRING, TRY(write_dst(flags.tabs ? INDENT_TAB_STRING : INDENT_SPACES_STRING,