Add quiet flag to amduat-asl
This commit is contained in:
parent
f406e1d10a
commit
93d9f87783
|
|
@ -47,6 +47,7 @@ typedef struct {
|
|||
const char *profile;
|
||||
const char *hash;
|
||||
bool force;
|
||||
bool quiet;
|
||||
} amduat_asl_cli_init_opts_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -57,6 +58,7 @@ typedef struct {
|
|||
amduat_asl_cli_ref_format_t ref_format;
|
||||
bool has_type_tag;
|
||||
amduat_type_tag_t type_tag;
|
||||
bool quiet;
|
||||
} amduat_asl_cli_put_opts_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -68,6 +70,7 @@ typedef struct {
|
|||
bool has_expect_type_tag;
|
||||
amduat_type_tag_t expect_type_tag;
|
||||
bool print_type_tag;
|
||||
bool quiet;
|
||||
} amduat_asl_cli_get_opts_t;
|
||||
|
||||
static void amduat_asl_cli_print_usage(FILE *stream) {
|
||||
|
|
@ -75,14 +78,16 @@ static void amduat_asl_cli_print_usage(FILE *stream) {
|
|||
"usage:\n"
|
||||
" amduat-asl init [--root PATH] [--store-id ID]\n"
|
||||
" [--profile PROFILE_ID|name]\n"
|
||||
" [--hash HASH_ID|name] [--force]\n"
|
||||
" [--hash HASH_ID|name] [--force] [--quiet]\n"
|
||||
" amduat-asl put [--root PATH] [--type-tag TAG]\n"
|
||||
" [--input PATH|-] [--input-format raw|artifact]\n"
|
||||
" [--ref-format hex|bytes] [--output PATH|-]\n"
|
||||
" [--quiet]\n"
|
||||
" amduat-asl get --ref REF [--root PATH]\n"
|
||||
" [--ref-format hex|bytes] [--output PATH|-]\n"
|
||||
" [--output-format raw|artifact]\n"
|
||||
" [--expect-type-tag TAG] [--print-type-tag]\n"
|
||||
" [--quiet]\n"
|
||||
"\n"
|
||||
"defaults:\n"
|
||||
" --root %s\n"
|
||||
|
|
@ -608,6 +613,8 @@ static int amduat_asl_cli_cmd_init(int argc, char **argv) {
|
|||
opts.hash = argv[++i];
|
||||
} else if (strcmp(argv[i], "--force") == 0) {
|
||||
opts.force = true;
|
||||
} else if (strcmp(argv[i], "--quiet") == 0) {
|
||||
opts.quiet = true;
|
||||
} else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
|
||||
amduat_asl_cli_print_usage(stdout);
|
||||
return AMDUAT_ASL_CLI_EXIT_OK;
|
||||
|
|
@ -642,7 +649,7 @@ static int amduat_asl_cli_cmd_init(int argc, char **argv) {
|
|||
ok = amduat_asl_store_fs_init_root(opts.root, &cfg_in, &cfg_out);
|
||||
if (!ok && opts.force) {
|
||||
ok = amduat_asl_store_fs_init_root(opts.root, NULL, &cfg_out);
|
||||
if (ok && (opts.store_id || opts.profile || opts.hash)) {
|
||||
if (ok && (opts.store_id || opts.profile || opts.hash) && !opts.quiet) {
|
||||
fprintf(stderr,
|
||||
"warning: existing config kept; overrides ignored\n");
|
||||
}
|
||||
|
|
@ -653,8 +660,10 @@ static int amduat_asl_cli_cmd_init(int argc, char **argv) {
|
|||
return AMDUAT_ASL_CLI_EXIT_CONFIG;
|
||||
}
|
||||
|
||||
if (!opts.quiet) {
|
||||
fprintf(stderr, "root=%s\n", opts.root);
|
||||
amduat_asl_cli_print_store_meta(&cfg_out);
|
||||
}
|
||||
return AMDUAT_ASL_CLI_EXIT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -726,6 +735,8 @@ static int amduat_asl_cli_cmd_put(int argc, char **argv) {
|
|||
return AMDUAT_ASL_CLI_EXIT_USAGE;
|
||||
}
|
||||
opts.output_path = argv[++i];
|
||||
} else if (strcmp(argv[i], "--quiet") == 0) {
|
||||
opts.quiet = true;
|
||||
} else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
|
||||
amduat_asl_cli_print_usage(stdout);
|
||||
return AMDUAT_ASL_CLI_EXIT_OK;
|
||||
|
|
@ -814,7 +825,7 @@ static int amduat_asl_cli_cmd_put(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
if (exit_code == AMDUAT_ASL_CLI_EXIT_OK) {
|
||||
if (exit_code == AMDUAT_ASL_CLI_EXIT_OK && !opts.quiet) {
|
||||
char *hex_ref = NULL;
|
||||
fprintf(stderr, "root=%s\n", opts.root);
|
||||
amduat_asl_cli_print_store_meta(&cfg);
|
||||
|
|
@ -910,6 +921,8 @@ static int amduat_asl_cli_cmd_get(int argc, char **argv) {
|
|||
opts.has_expect_type_tag = true;
|
||||
} else if (strcmp(argv[i], "--print-type-tag") == 0) {
|
||||
opts.print_type_tag = true;
|
||||
} else if (strcmp(argv[i], "--quiet") == 0) {
|
||||
opts.quiet = true;
|
||||
} else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
|
||||
amduat_asl_cli_print_usage(stdout);
|
||||
return AMDUAT_ASL_CLI_EXIT_OK;
|
||||
|
|
@ -999,7 +1012,7 @@ static int amduat_asl_cli_cmd_get(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
if (exit_code == AMDUAT_ASL_CLI_EXIT_OK) {
|
||||
if (exit_code == AMDUAT_ASL_CLI_EXIT_OK && !opts.quiet) {
|
||||
fprintf(stderr, "root=%s\n", opts.root);
|
||||
amduat_asl_cli_print_store_meta(&cfg);
|
||||
fprintf(stderr, "bytes=%zu\n", artifact.bytes.len);
|
||||
|
|
|
|||
Loading…
Reference in a new issue