-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Finishes addressing issue #29 Adds a Settings struct for creating parsers/commands with NewParserWithSettings or NewCommandWithSettings. Settings HelpDisabled - defaults false, set true to not generate a help argument for parser/command HelpSname - short name for the parser/command help argument. Can be left empty HelpLname - long name for the parser/command help argument. Leaving empty forces use of -h/--help when HelpDisabled is false NoExitOnHelp - defaults false, set true to not exit on help argument being parsed Should resolve all outstanding help argument issues. * Finishing Issue #29 Fixed merge conflict error due to check function return type change confusion. * Updated Settings Object to multiple function calls Added functions: DisableHelp SetHelp ExitOnHelp Added Command.exitOnHelp Added more tests to increase code coverage * Updated no help example
- Loading branch information
1 parent
48862cb
commit 6876ef2
Showing
8 changed files
with
292 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package argparse | ||
|
||
import "fmt" | ||
import ( | ||
"fmt" | ||
) | ||
|
||
func ExampleCommand_Help() { | ||
parser := NewParser("parser", "") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/akamensky/argparse" | ||
) | ||
|
||
func main() { | ||
// Create new parser object | ||
parser := argparse.NewParser("help", "Demonstrates changing the help argument names") | ||
parser.SetHelp("e", "example") | ||
// Create string flag | ||
parser.String("s", "string", &argparse.Options{Required: false, Help: "String argument example"}) | ||
// Create string flag | ||
parser.Int("i", "int", &argparse.Options{Required: false, Help: "Integer argument example"}) | ||
// Use the help function | ||
fmt.Print(parser.Parse([]string{"parser", "-e"})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/akamensky/argparse" | ||
) | ||
|
||
func main() { | ||
// Create new parser object | ||
parser := argparse.NewParser("help", "Demonstrates changing the help argument names") | ||
parser.ExitOnHelp(false) | ||
// Create string flag | ||
parser.String("s", "string", &argparse.Options{Required: false, Help: "String argument example"}) | ||
// Create string flag | ||
parser.Int("i", "int", &argparse.Options{Required: false, Help: "Integer argument example"}) | ||
// Use the help function | ||
fmt.Println(parser.Parse([]string{"parser", "-h"})) | ||
fmt.Println("Didn't exit, still printing") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/akamensky/argparse" | ||
) | ||
|
||
func main() { | ||
// Create new parser object | ||
parser := argparse.NewParser("help", "Demonstrates disabing the help arguments") | ||
parser.DisableHelp() | ||
// Create string flag | ||
parser.String("s", "string", &argparse.Options{Required: false, Help: "String argument example"}) | ||
// Create string flag | ||
parser.Int("i", "int", &argparse.Options{Required: false, Help: "Integer argument example"}) | ||
|
||
// parsing for -h fails | ||
fmt.Println(parser.Parse([]string{"parser", "-h", "--help", "-s", "testing", "-i", "5"})) | ||
} |