Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to print possible values ​​for --format #693

Open
sorairolake opened this issue Jul 22, 2024 · 7 comments
Open

Change to print possible values ​​for --format #693

sorairolake opened this issue Jul 22, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@sorairolake
Copy link

sorairolake commented Jul 22, 2024

Currently, --format takes a OsString value.

ouch/src/cli/args.rs

Lines 40 to 42 in 4a323ae

/// Specify the format of the archive
#[arg(short, long, global = true)]
pub format: Option<OsString>,

Change this to the following:

/// Specify the format of the archive
#[arg(short, long, global = true)]
pub format: Option<Format>,

...

#[derive(Clone, Debug, ValueEnum)]
pub enum Format {
    /// .tar
    #[value(alias(".tar"))]
    Tar,

    /// .xz
    #[value(alias(".xz"))]
    Xz,

    /// .tar.zst or .tzst
    #[value(name("tar.zst"), alias(".tar.zst"), alias("tzst"), alias(".tzst"))]
    TarZst,

    ...
}

I think this will allow --format to print possible values.

The downside to this is that it makes complex chains of file formats such as .tar.gz.xz.zst.gz.lz4.sz impossible.

@sorairolake sorairolake added the enhancement New feature or request label Jul 22, 2024
@marcospb19
Copy link
Member

I think this will allow --format to print possible values.

Hey! By print, do you mean --help or shell autocompletion?

@sorairolake
Copy link
Author

I think this will allow --format to print possible values.

Hey! By print, do you mean --help or shell autocompletion?

Yes, that's right.

@marcospb19
Copy link
Member

I'm sorry, which one of these two? hahaha

@sorairolake
Copy link
Author

@marcospb19 Both. -h prints possible values, and --help prints the help description (doc comments) in addition to this. For shell completion, possible values ​​will be completed if supported. If the help description is supported it will also be printed.

@sorairolake
Copy link
Author

To avoid breaking changes to --format, it may be better to add new options rather than modifying --format. I think it would be better to have the new options separate for compression formats and archive formats to limit the number of possible values.

e.g., --compression-format=gzip and --archive-format=tar.

@marcospb19
Copy link
Member

I can't think of a scenario where this would break --format 🤔.

@sorairolake
Copy link
Author

I can't think of a scenario where this would break --format 🤔.

I think this will not be able to handle complex chains .tar.gz.xz.zst.gz.lz4.sz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants