From bce2dbecb9a3c524bf3cfdc3ab42f0f34729e76b Mon Sep 17 00:00:00 2001 From: sigoden Date: Mon, 24 Jun 2024 07:37:50 +0800 Subject: [PATCH] refactor: cli help and shell completions (#642) --- README.md | 2 +- scripts/completions/aichat.bash | 2 +- scripts/completions/aichat.fish | 6 ++-- scripts/completions/aichat.nu | 50 ++++++++++++++++----------------- scripts/completions/aichat.ps1 | 12 ++++---- scripts/completions/aichat.zsh | 12 ++++---- src/cli.rs | 8 +++--- 7 files changed, 46 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 59bb03b..0ef4cc1 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ Options: -c, --code Output code only -f, --file Include files with the message -H, --no-highlight Turn off syntax highlighting - -S, --no-stream Turns off stream mode + -S, --no-stream Turn off stream mode -w, --wrap Control text wrapping (no, auto, ) --light-theme Use light theme --dry-run Display the message without sending it diff --git a/scripts/completions/aichat.bash b/scripts/completions/aichat.bash index afc81f5..a4ac09e 100644 --- a/scripts/completions/aichat.bash +++ b/scripts/completions/aichat.bash @@ -19,7 +19,7 @@ _aichat() { case "${cmd}" in aichat) - opts="-m -r -s -a -R -e -c -f -H -S -w -h -V --model --prompt --role --session --save-session --agent --rag --serve --execute --code --file --no-highlight --no-stream --wrap --light-theme --dry-run --info --list-models --list-roles --list-sessions --list-agents --list-rags --help --version" + opts="-m -r -s -a -R -e -c -f -S -w -H -h -V --model --prompt --role --session --save-session --agent --rag --serve --execute --code --file --no-stream --wrap --no-highlight --light-theme --dry-run --info --list-models --list-roles --list-sessions --list-agents --list-rags --help --version" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 diff --git a/scripts/completions/aichat.fish b/scripts/completions/aichat.fish index 4a926c9..2bd8cba 100644 --- a/scripts/completions/aichat.fish +++ b/scripts/completions/aichat.fish @@ -5,13 +5,13 @@ complete -c aichat -s s -l session -x -a"(aichat --list-sessions)" -d 'Start or complete -c aichat -l save-session -d 'Forces the session to be saved' complete -c aichat -s a -l agent -x -a"(aichat --list-agents)" -d 'Start a agent' -r complete -c aichat -s R -l rag -x -a"(aichat --list-rags)" -d 'Start a RAG' -r -complete -c aichat -s f -l file -d 'Include files with the message' -r -F -complete -c aichat -s w -l wrap -d 'Control text wrapping (no, auto, )' complete -c aichat -l serve -d 'Serve the LLM API and WebAPP' complete -c aichat -s e -l execute -d 'Execute commands in natural language' complete -c aichat -s c -l code -d 'Output code only' +complete -c aichat -s f -l file -d 'Include files with the message' -r -F +complete -c aichat -s S -l no-stream -d 'Turn off stream mode' +complete -c aichat -s w -l wrap -d 'Control text wrapping (no, auto, )' complete -c aichat -s H -l no-highlight -d 'Turn off syntax highlighting' -complete -c aichat -s S -l no-stream -d 'Turns off stream mode' complete -c aichat -l light-theme -d 'Use light theme' complete -c aichat -l dry-run -d 'Display the message without sending it' complete -c aichat -l info -d 'Display information' diff --git a/scripts/completions/aichat.nu b/scripts/completions/aichat.nu index 4a3d189..6c370aa 100644 --- a/scripts/completions/aichat.nu +++ b/scripts/completions/aichat.nu @@ -36,31 +36,31 @@ module completions { # All-in-one chat and copilot CLI that integrates 10+ AI platforms export extern aichat [ - --model(-m): string@"nu-complete aichat model" # Select a LLM model - --prompt # Use the system prompt - --role(-r): string@"nu-complete aichat role" # Select a role - --session(-s): string@"nu-complete aichat role" # Start or join a session - --save-session # Forces the session to be saved - --agent(-a): string@"nu-complete aichat agent" # Start a agent - --rag(-R): string@"nu-complete aichat rag" # Start a RAG - --serve # Serve the LLM API and WebAPP - --execute(-e) # Execute commands in natural language - --code(-c) # Output code only - --file(-f): string # Include files with the message - --no-highlight(-H) # Turn off syntax highlighting - --no-stream(-S) # Turns off stream mode - --wrap(-w): string # Control text wrapping (no, auto, ) - --light-theme # Use light theme - --dry-run # Display the message without sending it - --info # Display information - --list-models # List all available chat models - --list-roles # List all roles - --list-sessions # List all sessions - --list-agents # List all agents - --list-rags # List all RAGs - ...text: string # Input text - --help(-h) # Print help - --version(-V) # Print version + --model(-m): string@"nu-complete aichat model" # Select a LLM model + --prompt # Use the system prompt + --role(-r): string@"nu-complete aichat role" # Select a role + --session(-s): string@"nu-complete aichat session" # Start or join a session + --save-session # Forces the session to be saved + --agent(-a): string@"nu-complete aichat agent" # Start a agent + --rag(-R): string@"nu-complete aichat rag" # Start a RAG + --serve # Serve the LLM API and WebAPP + --execute(-e) # Execute commands in natural language + --code(-c) # Output code only + --file(-f): string # Include files with the message + --no-stream(-S) # Turn off stream mode + --wrap(-w): string # Control text wrapping (no, auto, ) + --no-highlight(-H) # Turn off syntax highlighting + --light-theme # Use light theme + --dry-run # Display the message without sending it + --info # Display information + --list-models # List all available chat models + --list-roles # List all roles + --list-sessions # List all sessions + --list-agents # List all agents + --list-rags # List all RAGs + ...text: string # Input text + --help(-h) # Print help + --version(-V) # Print version ] } diff --git a/scripts/completions/aichat.ps1 b/scripts/completions/aichat.ps1 index dd0dc9c..37fe5e1 100644 --- a/scripts/completions/aichat.ps1 +++ b/scripts/completions/aichat.ps1 @@ -32,19 +32,19 @@ Register-ArgumentCompleter -Native -CommandName 'aichat' -ScriptBlock { [CompletionResult]::new('--agent', '--agent', [CompletionResultType]::ParameterName, 'Start a agent') [CompletionResult]::new('-R', '-R', [CompletionResultType]::ParameterName, 'Start a RAG') [CompletionResult]::new('--rag', '--rag', [CompletionResultType]::ParameterName, 'Start a RAG') - [CompletionResult]::new('-f', '-f', [CompletionResultType]::ParameterName, 'Include files with the message') - [CompletionResult]::new('--file', '--file', [CompletionResultType]::ParameterName, 'Include files with the message') - [CompletionResult]::new('-w', '-w', [CompletionResultType]::ParameterName, 'Control text wrapping (no, auto, )') - [CompletionResult]::new('--wrap', '--wrap', [CompletionResultType]::ParameterName, 'Control text wrapping (no, auto, )') [CompletionResult]::new('--serve', '--serve', [CompletionResultType]::ParameterName, 'Serve the LLM API and WebAPP') [CompletionResult]::new('-e', '-e', [CompletionResultType]::ParameterName, 'Execute commands in natural language') [CompletionResult]::new('--execute', '--execute', [CompletionResultType]::ParameterName, 'Execute commands in natural language') [CompletionResult]::new('-c', '-c', [CompletionResultType]::ParameterName, 'Output code only') [CompletionResult]::new('--code', '--code', [CompletionResultType]::ParameterName, 'Output code only') + [CompletionResult]::new('-f', '-f', [CompletionResultType]::ParameterName, 'Include files with the message') + [CompletionResult]::new('--file', '--file', [CompletionResultType]::ParameterName, 'Include files with the message') + [CompletionResult]::new('-S', '-S', [CompletionResultType]::ParameterName, 'Turn off stream mode') + [CompletionResult]::new('--no-stream', '--no-stream', [CompletionResultType]::ParameterName, 'Turn off stream mode') + [CompletionResult]::new('-w', '-w', [CompletionResultType]::ParameterName, 'Control text wrapping (no, auto, )') + [CompletionResult]::new('--wrap', '--wrap', [CompletionResultType]::ParameterName, 'Control text wrapping (no, auto, )') [CompletionResult]::new('-H', '-H', [CompletionResultType]::ParameterName, 'Turn off syntax highlighting') [CompletionResult]::new('--no-highlight', '--no-highlight', [CompletionResultType]::ParameterName, 'Turn off syntax highlighting') - [CompletionResult]::new('-S', '-S', [CompletionResultType]::ParameterName, 'Turns off stream mode') - [CompletionResult]::new('--no-stream', '--no-stream', [CompletionResultType]::ParameterName, 'Turns off stream mode') [CompletionResult]::new('--light-theme', '--light-theme', [CompletionResultType]::ParameterName, 'Use light theme') [CompletionResult]::new('--dry-run', '--dry-run', [CompletionResultType]::ParameterName, 'Display the message without sending it') [CompletionResult]::new('--info', '--info', [CompletionResultType]::ParameterName, 'Display information') diff --git a/scripts/completions/aichat.zsh b/scripts/completions/aichat.zsh index 45da3ca..b311f6a 100644 --- a/scripts/completions/aichat.zsh +++ b/scripts/completions/aichat.zsh @@ -27,19 +27,19 @@ _aichat() { '--agent[Start a agent]:AGENT:->agents' \ '-R[Start a RAG]:RAG:->rags' \ '--rag[Start a RAG]:RAG:->rags' \ -'*-f[Include files with the message]:FILE:_files' \ -'*--file[Include files with the message]:FILE:_files' \ -'-w[Control text wrapping (no, auto, )]:WRAP: ' \ -'--wrap[Control text wrapping (no, auto, )]:WRAP: ' \ '--serve[Serve the LLM API and WebAPP]' \ '-e[Execute commands in natural language]' \ '--execute[Execute commands in natural language]' \ '-c[Output code only]' \ '--code[Output code only]' \ +'*-f[Include files with the message]:FILE:_files' \ +'*--file[Include files with the message]:FILE:_files' \ +'-S[Turn off stream mode]' \ +'--no-stream[Turn off stream mode]' \ +'-w[Control text wrapping (no, auto, )]:WRAP: ' \ +'--wrap[Control text wrapping (no, auto, )]:WRAP: ' \ '-H[Turn off syntax highlighting]' \ '--no-highlight[Turn off syntax highlighting]' \ -'-S[Turns off stream mode]' \ -'--no-stream[Turns off stream mode]' \ '--light-theme[Use light theme]' \ '--dry-run[Display the message without sending it]' \ '--info[Display information]' \ diff --git a/src/cli.rs b/src/cli.rs index 243fc82..7811158 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -36,15 +36,15 @@ pub struct Cli { /// Include files with the message #[clap(short = 'f', long, value_name = "FILE")] pub file: Vec, - /// Turn off syntax highlighting - #[clap(short = 'H', long)] - pub no_highlight: bool, - /// Turns off stream mode + /// Turn off stream mode #[clap(short = 'S', long)] pub no_stream: bool, /// Control text wrapping (no, auto, ) #[clap(short = 'w', long)] pub wrap: Option, + /// Turn off syntax highlighting + #[clap(short = 'H', long)] + pub no_highlight: bool, /// Use light theme #[clap(long)] pub light_theme: bool,