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

allow empty string in @:command("", "foo", "bar") #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion src/tink/cli/Macro.hx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,11 @@ class Macro {
case [{params: []}]:
commands.push(field.name);
case [{params: params}]:
for(p in params) commands.push(p.getString().sure());
for(p in params)
if (p.getString().sure() == "")
commands.push(field.name);
else
commands.push(p.getString().sure());
case v:
v[1].pos.makeFailure('Multiple @:command meta is not allowed').sure();
}
Expand Down
19 changes: 17 additions & 2 deletions tests/TestCommand.hx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ class TestCommand {
return Cli.process([cmd], command)
.map(function(_) return assert(command.result() == 'multi'));
}

@:describe('Multi with "" taking name from function')
@:variant('multi_again1')
@:variant('multi_again2')
@:variant('multi_again')
public function testMultiNameAgain(cmd:String) {
var command = new EntryCommand();
return Cli.process([cmd], command)
.map(function(_) return assert(command.result() == 'multi_again'));
}

@:describe('Rest Arguments')
@:variant(['rest', 'a', 'b'], null)
Expand Down Expand Up @@ -123,7 +133,12 @@ class EntryCommand extends DebugCommand {
public function multi() {
debug = 'multi';
}


@:command('', 'multi_again1', 'multi_again2')
public function multi_again() {
debug = 'multi_again';
}

@:command
public function rest(a:String, b:String, c:Rest<String>, d:String) {
debug = 'rest $a $b ${c.join(',')} $d';
Expand All @@ -148,4 +163,4 @@ class InitCommand extends DebugCommand{
public function defaultInit(args:Rest<String>) {
debug = 'defaultInit ' + args.join(',');
}
}
}