8000 enhance function with argparse · Issue #5835 · fish-shell/fish-shell · GitHub
[go: up one dir, main page]

Skip to content

enhance function with argparse #5835

@danielb2

Description

@danielb2

fish, version 3.0.2

Currently function takes option -a NAMES (among) others to assign readable names to arguments.

It would be nice if an --flag option was also available which makes use of the built-in argparse command.

Example usage:

function recode -a input --flag "h/help" --flag "e/encoding" -d "use ffmpeg to convert a video file to another format"
  
  if [_$flag_h]
    fish_func_help()
  end
  
  set extension (string replace -i -r '^.*?(\w*)$' '$1' $input)
  set output (string replace -r '\.([^.]*)$' .$_flag_encoding $input).$extension
  
  ffmpeg -i "$input" -c:v $_flag_encoding -c:a copy -c:s copy "$output"
end

Since function is already aware of the name of the function and what options are available for argparse, it should be able to output a nice help message as well (current argparse error is a bit much)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0