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

Don't trigger alr help on alr exec -- command --help #1491

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion alire.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ windows = { ALIRE_OS = "windows" }
[[pins]]
aaa = { url = "https://github.com/mosteo/aaa", commit = "ecc38772bd4a6b469b54c62363766ea1c0e9f912" }
ada_toml = { url = "https://github.com/mosteo/ada-toml", commit = "da4e59c382ceb0de6733d571ecbab7ea4919b33d" }
clic = { url = "https://github.com/alire-project/clic", commit = "b40b170b1561adfa99910c69e3897cc2ca441730" }
clic = { url = "https://github.com/alire-project/clic", commit = "de0330053584bad4dbb3dbd5e1ba939c4e8c6b55" }
dirty_booleans = { url = "https://github.com/mosteo/dirty_booleans", branch = "main" }
diskflags = { url = "https://github.com/mosteo/diskflags", branch = "main" }
gnatcoll = { url = "https://github.com/alire-project/gnatcoll-core.git", commit = "4e663b87a028252e7e074f054f8f453661397166" }
Expand Down
2 changes: 1 addition & 1 deletion deps/clic
2 changes: 1 addition & 1 deletion src/alire/alire-os_lib-subprocess.adb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ package body Alire.OS_Lib.Subprocess is

Raise_Checked_Error
("Command " & Image (Command, Arguments)
& " exited with code" & Exit_Code'Img
& " exited with code" & AAA.Strings.Trim (Exit_Code'Image)
& " and output: " & Output.Flatten (Separator => "\n"));

return Output;
Expand Down
8 changes: 0 additions & 8 deletions src/alr/alr-commands.adb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ package body Alr.Commands is
Debug_Channel : Boolean renames Alire_Early_Elaboration.Switch_D;
-- For the stderr debug channel

Help_Switch : aliased Boolean := False;
-- Catches the -h/--help help switch

Prefer_Oldest : aliased Boolean := False;
-- Catches the --prefer-oldest policy switch

Expand Down Expand Up @@ -155,11 +152,6 @@ package body Alr.Commands is
"-f", "--force",
"Keep going after a recoverable troublesome situation");

Define_Switch (Config,
Help_Switch'Access,
"-h", "--help",
"Display general or command-specific help");

Define_Switch (Config,
CLIC.User_Input.Not_Interactive'Access,
"-n", "--non-interactive",
Expand Down
31 changes: 31 additions & 0 deletions testsuite/tests/help/help-after-double-dash/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Bug #1379: -h/--help must not trigger our help system after a "--" argument
"""

import re

from drivers.alr import init_local_crate, run_alr
from drivers.asserts import assert_match

# For no command, "--" with help afterwards should simply trigger an error

assert_match(".*" + re.escape("Unrecognized option '--' (global)"),
run_alr("--", "--help", complain_on_error=False).out)

# For a command that doesn't understand "--", same:

assert_match(".*" + re.escape("Unrecognized option '--' (command/topic \"show\")"),
run_alr("show", "--", "--help", complain_on_error=False).out)

# For `alr exec`, it should trigger the secondary command help and not ours. We
# verify the command being launched includes the "--help" option. Since `exec`
# requires a workspace, we enter one first.

init_local_crate()

assert_match(".*" + re.escape('Command ["alr_fake", "--help"] exited with code'),
run_alr("exec", "--", "alr_fake", "--help",
complain_on_error=False).out)
# We don't match the code as it varies between OSes

print("SUCCESS")
3 changes: 3 additions & 0 deletions testsuite/tests/help/help-after-double-dash/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
driver: python-script
build_mode: both
indexes: {}
Loading