Skip to content

Add support for --no-flags#46

Merged
amireh merged 1 commit intolunarmodules:masterfrom
o-lim:no-flags
Mar 29, 2015
Merged

Add support for --no-flags#46
amireh merged 1 commit intolunarmodules:masterfrom
o-lim:no-flags

Conversation

@o-lim
Copy link
Contributor

@o-lim o-lim commented Mar 7, 2015

This allows command-line flags to be defaulted to on, allowing the user to turn off the flag on the command-line.

local cli = require 'cliargs'
cli:set_name('myapp')
cli:add_flag('--[no-]flag', 'flag description', true)
local args = cli:parse(arg)
if args.flag then
  print('flag is on')
else
  print('flag is off')
end
$ lua myapp.lua
flag is on
$ lua myapp.lua --no-flag
flag is off
$ lua myapp.lua --flag
flag is on

@Tieske
Copy link
Member

Tieske commented Mar 7, 2015

+1

This allows command-line flags with a default set to `on`, allowing the
user to turn off the flag on the command-line.
@o-lim
Copy link
Contributor Author

o-lim commented Mar 29, 2015

@amireh any chances of a merge?

@amireh
Copy link
Collaborator

amireh commented Mar 29, 2015

Yes, i'm merging this now.

We could use an example, I'll add that before the release.

amireh added a commit that referenced this pull request Mar 29, 2015
Add support for --no-flags
@amireh amireh merged commit ce195a4 into lunarmodules:master Mar 29, 2015
@amireh
Copy link
Collaborator

amireh commented Mar 29, 2015

Thank you, @o-lim!

@o-lim
Copy link
Contributor Author

o-lim commented Mar 30, 2015

Sounds great. Thanks!

@amireh
Copy link
Collaborator

amireh commented Mar 30, 2015

This is now available in lua_cliargs v2.5-0.

@o-lim o-lim deleted the no-flags branch March 30, 2015 01:16
@o-lim
Copy link
Contributor Author

o-lim commented Mar 30, 2015

It looks like in the v2.5 tag and release, cli._VERSION still says "cliargs 2.4-1"

@amireh
Copy link
Collaborator

amireh commented Mar 30, 2015

Ugh, I'll fix in a 2.5-1 release tomorrow morning. Maybe I'll finally have the publish script do this since I obviously can't do it ._.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants