Skip to content

CLI: simplify and make friendlier and more Unix-like #100

@murlakatamenka

Description

@murlakatamenka

Here are some of the issues:

  1. Long flags should be made kebab case for readability:
  • --listoutputs -> --list-outputs
  • --choseoutputs -> --choose-outputs

cp, mv, curl, wget, rg have it like that.

  1. --file <PATH> and --stdout can be replaced with optional [FILE] argument.
match `FILE` {
    Some('-') => // stdout
    Some(path) => // write to path
    None => {
       // write <unixtime>-wayshot.png to current dir
       // print "Saved to <path>" to stdin/stdout, to make the default invocation obvious
    }
}

- for stdout is a common Unix convention.

  1. Help (--help)
  • move --debug to the end of the help, because that's not what a user typically looks for when learning how to use a new tool
  • specify supported extensions. Now they are only mentioned in README and manpage
  • colors! Clap v4 can have clap v3 colored help or custom style, for example, I like rustic's (permalink)
  1. --list-outputs

Currently, output of --list-outputs isn't suitable to pipe to another selector (fzf/skim or GUI dmenu-like fuzzel, wofi), because it's done via tracing:

if args.get_flag("listoutputs") {
let valid_outputs = wayshot_conn.get_all_outputs();
for output in valid_outputs {
tracing::info!("{:#?}", output.name);
}
exit(1);
}

It's output to stderr and exits with an error code 1 for no reason.

Should be: just 1 output per line to stdout, and 0 exit code. Good for:

wayshot --output "$(wayshot --list-outputs | fuzzel --dmenu)"

to be bound to a specific hotkey, like PrintScreen.

  1. Add TAB-completion

clap is used for CLI, clap_complete is one step away. Completion scripts can be generated during build time, there is already bulid.rs in the project


I'll make a draft PR to address those issues, to me all of them are straight improvements of wayshot's UX.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions