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

Forward unmodified ARGV to subcommand #631

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 21 additions & 0 deletions spec/integration/subcommand_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require "./spec_helper"

describe "subcommand" do
it "forwards all arguments to subcommand" do
create_shard("dummy", "0.1.0")
create_executable "dummy", "bin/shards-dummy", %(print "args: "; print ARGV)
luislavena marked this conversation as resolved.
Show resolved Hide resolved

with_path(git_path("dummy/bin")) do
output = run("shards dummy --no-color --verbose --unknown other argument")
output.should contain(%(args: ["--no-color", "--verbose", "--unknown", "other", "argument"]))
end
end
end

private def with_path(path)
old_path = ENV["PATH"]
ENV["PATH"] = "#{File.expand_path(path)}#{Process::PATH_DELIMITER}#{ENV["PATH"]}"
yield
ensure
ENV["PATH"] = old_path
end
4 changes: 2 additions & 2 deletions src/cli.cr
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module Shards
else
program_name = "shards-#{args[0]}"
if program_path = Process.find_executable(program_name)
run_shards_subcommand(program_path, args)
run_shards_subcommand(program_path, cli_options)
else
display_help_and_exit(opts)
end
Expand All @@ -119,7 +119,7 @@ module Shards
{% else %}
shards_opts = ENV.fetch("SHARDS_OPTS", "").split
{% end %}
ARGV.concat(shards_opts)
ARGV.dup.concat(shards_opts)
luislavena marked this conversation as resolved.
Show resolved Hide resolved
end

def self.run_shards_subcommand(process_name, args)
Expand Down