From ea90b329f09b2873ad39cc03cd5d9509fe1bc2d9 Mon Sep 17 00:00:00 2001 From: Francesc Rocher Date: Mon, 18 Mar 2024 18:59:49 +0100 Subject: [PATCH] Rename switch arguments to indicate expected type (#1650) In commands with options that admit arguments, like '--prefix' in 'alr install', is useful to provide an argument name in the command help that gives a hint of the expected type. For example, 'alr install -h' shows the message: ==== OPTIONS --prefix=ARG Override installation prefix (default is ...) ==== When changed to: ==== OPTIONS --prefix=DIR Override installation prefix (default is ...) ==== the 'DIR' name of the argument immediately says what is expected in this option. In cases where this is not so obvious, it helps even more. For example, in 'alr build -h': ==== OPTIONS --profiles=LIST Comma-separated list of = values (see description) --stop-after=STAGE Build stage after which to stop (see description) ==== is a quick remainder of what is expected in that options. --- src/alr/alr-commands-build.adb | 6 ++++-- src/alr/alr-commands-edit.adb | 3 ++- src/alr/alr-commands-exec.adb | 3 ++- src/alr/alr-commands-install.adb | 3 ++- src/alr/alr-commands-publish.adb | 3 ++- src/alr/alr-commands-show.adb | 4 ++-- src/alr/alr-commands.adb | 6 ++++-- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/alr/alr-commands-build.adb b/src/alr/alr-commands-build.adb index 92c8afe2..0e555e58 100644 --- a/src/alr/alr-commands-build.adb +++ b/src/alr/alr-commands-build.adb @@ -273,13 +273,15 @@ package body Alr.Commands.Build is (Config, Cmd.Profiles'Access, "", Switch_Profiles & "=", - "Comma-separated list of = values (see description)"); + "Comma-separated list of = values (see description)", + Argument => "LIST"); Define_Switch (Config, Cmd.Stop_After'Access, "", Switch_Stop & "=", - "Build stage after which to stop (see description)"); + "Build stage after which to stop (see description)", + Argument => "STAGE"); end Setup_Switches; diff --git a/src/alr/alr-commands-edit.adb b/src/alr/alr-commands-edit.adb index 36758d15..dbfc1a57 100644 --- a/src/alr/alr-commands-edit.adb +++ b/src/alr/alr-commands-edit.adb @@ -276,7 +276,8 @@ package body Alr.Commands.Edit is Cmd.Prj'Access, "", "--project=", "Select the project file to open if the crate " & - "provides multiple project files, ignored otherwise"); + "provides multiple project files, ignored otherwise", + Argument => "FILE"); Define_Switch (Config, Cmd.Set'Access, "", "--select-editor", diff --git a/src/alr/alr-commands-exec.adb b/src/alr/alr-commands-exec.adb index cf50a2bc..73ffc9ca 100644 --- a/src/alr/alr-commands-exec.adb +++ b/src/alr/alr-commands-exec.adb @@ -123,7 +123,8 @@ package body Alr.Commands.Exec is (Config, Cmd.Prj'Access, Switch => "-P?", - Help => "Add ""-P "" to the command switches"); + Help => "Add ""-P "" to the command switches", + Argument => "NUM"); end Setup_Switches; end Alr.Commands.Exec; diff --git a/src/alr/alr-commands-install.adb b/src/alr/alr-commands-install.adb index 974885a6..2f530135 100644 --- a/src/alr/alr-commands-install.adb +++ b/src/alr/alr-commands-install.adb @@ -141,7 +141,8 @@ package body Alr.Commands.Install is Cmd.Prefix'Access, "", "--prefix=", "Override installation prefix (default is " - & TTY.URL (Alire.Install.Default_Prefix) & ")"); + & TTY.URL (Alire.Install.Default_Prefix) & ")", + Argument => "DIR"); Define_Switch (Config, Cmd.Info'Access, diff --git a/src/alr/alr-commands-publish.adb b/src/alr/alr-commands-publish.adb index 67c3455d..018669eb 100644 --- a/src/alr/alr-commands-publish.adb +++ b/src/alr/alr-commands-publish.adb @@ -151,7 +151,8 @@ package body Alr.Commands.Publish is (Config, Cmd.Manifest'Access, "", "--manifest=", - "Selects a manifest file other than ./alire.toml"); + "Selects a manifest file other than ./alire.toml", + Argument => "FILE"); Define_Switch (Config, diff --git a/src/alr/alr-commands-show.adb b/src/alr/alr-commands-show.adb index e52f3872..9102f7c9 100644 --- a/src/alr/alr-commands-show.adb +++ b/src/alr/alr-commands-show.adb @@ -364,8 +364,8 @@ package body Alr.Commands.Show is Define_Switch (Config, Cmd.Dependents'Access, "", "--dependents?", - "Show dependent crates (ARG=direct|shortest|all)", - Argument => "=ARG"); + "Show dependent crates (WHICH=direct|shortest|all)", + Argument => "=WHICH"); Define_Switch (Config, Cmd.Detail'Access, diff --git a/src/alr/alr-commands.adb b/src/alr/alr-commands.adb index ef758482..43a50e3f 100644 --- a/src/alr/alr-commands.adb +++ b/src/alr/alr-commands.adb @@ -153,12 +153,14 @@ package body Alr.Commands is Define_Switch (Config, Command_Line_Config_Path'Access, "-s=", "--settings=", - "Override settings folder location"); + "Override settings folder location", + Argument => "DIR"); Define_Switch (Config, Command_Line_Chdir_Target_Path'Access, "-C=", "--chdir=", - "Run `alr` in the given directory"); + "Run `alr` in the given directory", + Argument => "DIR"); Define_Switch (Config, Alire.Force'Access, -- 2.39.5