From d3fc7f8b2d1fd319c8f2984e732d56e9f2b04f2e Mon Sep 17 00:00:00 2001 From: Jim Fitzpatrick Date: Sun, 28 Jun 2026 15:12:57 +0100 Subject: [PATCH 1/2] REFACTOR: cli args moved out of command call sites Signed-off-by: Jim Fitzpatrick --- src/args.zig | 40 ++++++++++++++++++++++++++++++++++++++++ src/diff.zig | 22 ++-------------------- src/get.zig | 27 ++------------------------- 3 files changed, 44 insertions(+), 45 deletions(-) diff --git a/src/args.zig b/src/args.zig index 45c5874..3f8aebd 100644 --- a/src/args.zig +++ b/src/args.zig @@ -1,5 +1,6 @@ const clap = @import("clap"); const logging = @import("log.zig"); +const types = @import("types.zig"); const SubCommands = enum { get, @@ -18,3 +19,42 @@ pub const main_params = clap.parseParamsComptime( \\ \\ ); + +pub const get_parsers = .{ + .OUTPUT = clap.parsers.enumeration(types.Output), + .STR = clap.parsers.string, + .PATH = clap.parsers.string, + .LEVEL = clap.parsers.enumeration(logging.Level), +}; + +pub const get_params = clap.parseParamsComptime( + \\-h, --help Display this help and exit. + \\-n, --namespace Namespace to get resources from. + \\-A, --all-namespaces If present, list all objects across all namespaces. Specifying --namespace will be ignored. + \\-s, --sort Prints the resources in order. + \\-e, --exclude ... Exclude crd types. Multiple can be excluded eg: "-e -e " + \\-o, --output Changes the output format of the results. [default: tty, tty|json|sqlite] + \\-d, --database Path to the sqlite file to save the results. If the files does not exist it will be created. + \\-l, --label Set the label that will be saved with entries when using the --database option. + \\--log-level Set the log level. All logs are saved to file. Possible values are (debug, info, warn, error). Default level is warn. + \\ +); + +pub const diff_parsers = .{ + .PATH = clap.parsers.string, + .STR = clap.parsers.string, + .LABEL = clap.parsers.string, + .LEVEL = clap.parsers.enumeration(logging.Level), + .OUTPUT = clap.parsers.enumeration(types.Output), +}; + +pub const diff_params = clap.parseParamsComptime( + \\-h, --help Display this help and exit. + \\-d, --database Path to SQLite database to load data from. + \\-e, --exclude ... Exclude resource types. Multiple can be excluded eg: "-e -e " + \\-o, --output Changes the output format of the results. [default: tty, tty|json] + \\--log-level Set the log level. All logs are saved to file. Possible values are (debug, info, warn, error). Default level is warn. + \\