mirror of
https://github.com/wneessen/apg-go.git
synced 2024-12-23 03:30:39 +01:00
v0.2.9: Replaced standard go-help with custom usage text
This commit is contained in:
parent
d3648d18a9
commit
0c371569c0
2 changed files with 49 additions and 2 deletions
|
@ -70,7 +70,27 @@
|
|||
<recent name="C:\Users\Winni Neessen\go\src\apg.go\test" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager" selected="Go Test.Benchmark Application">
|
||||
<component name="RunManager" selected="Go Build.Run Application (show help text)">
|
||||
<configuration name="Run Application (show help text)" type="GoApplicationRunConfiguration" factoryName="Go Application">
|
||||
<module name="apg.go" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
<parameters value="-h" />
|
||||
<kind value="PACKAGE" />
|
||||
<filePath value="$PROJECT_DIR$" />
|
||||
<package value="github.com/wneessen/apg.go" />
|
||||
<directory value="$PROJECT_DIR$" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Run Application (show version string)" type="GoApplicationRunConfiguration" factoryName="Go Application">
|
||||
<module name="apg.go" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
<parameters value="-v" />
|
||||
<kind value="PACKAGE" />
|
||||
<filePath value="$PROJECT_DIR$" />
|
||||
<package value="github.com/wneessen/apg.go" />
|
||||
<directory value="$PROJECT_DIR$" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Run Application (with excludes)" type="GoApplicationRunConfiguration" factoryName="Go Application">
|
||||
<module name="apg.go" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
|
@ -157,6 +177,8 @@
|
|||
<item itemvalue="Go Build.Run Application (with newstyle params)" />
|
||||
<item itemvalue="Go Build.Run Application (with newstyle params and spelling)" />
|
||||
<item itemvalue="Go Build.Run Application (with newstyle params and spelling and multiple pws)" />
|
||||
<item itemvalue="Go Build.Run Application (show help text)" />
|
||||
<item itemvalue="Go Build.Run Application (show version string)" />
|
||||
<item itemvalue="Go Test.Test Application" />
|
||||
<item itemvalue="Go Test.Benchmark Application" />
|
||||
</list>
|
||||
|
@ -206,7 +228,9 @@
|
|||
<MESSAGE value="Updated .gitignore" />
|
||||
<MESSAGE value="Removed .idea from .gitignore" />
|
||||
<MESSAGE value="Let's have centralized IDE config" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Let's have centralized IDE config" />
|
||||
<MESSAGE value="New DEV branch" />
|
||||
<MESSAGE value="v0.2.9: Replaced standard go-help with custom usage text" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="v0.2.9: Replaced standard go-help with custom usage text" />
|
||||
</component>
|
||||
<component name="VgoProject">
|
||||
<integration-enabled>true</integration-enabled>
|
||||
|
|
23
apg.go
23
apg.go
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
@ -28,12 +29,34 @@ type Config struct {
|
|||
outputMode int
|
||||
}
|
||||
|
||||
// Help text
|
||||
const usage = `Usage:
|
||||
apg [-m <length>] [-x <length>] -L -U -N -S -H
|
||||
apg [-m <length>] [-x <length>] -M LUNsh -E <list of chars>
|
||||
|
||||
Options:
|
||||
-m LENGTH Minimum length of the password to be generated (Default: 20)
|
||||
-x LENGTH Maximum length of the password to be generated (Default: 20)
|
||||
-n NUMBER Amount of password to be generated (Default: 1)
|
||||
-E CHARS List of characters to be excluded in the generated password
|
||||
-M [LUNSHClunshc] New style password parameters (upper case: on, lower case: off)
|
||||
-L Use lower case characters in passwords (Default: on)
|
||||
-U Use upper case characters in passwords (Default: on)
|
||||
-N Use numeric characters in passwords (Default: on)
|
||||
-S Use special characters in passwords (Default: on)
|
||||
-H Avoid ambiguous characters in passwords (i. e.: 1, l, I, O, 0) (Default: off)
|
||||
-C Enable complex password mode (implies -L -U -N -S and disables -H) (Default: off)
|
||||
-l Spell generated passwords in phonetic alphabet (Default: off)
|
||||
-h Show this help text
|
||||
-v Show version string`
|
||||
|
||||
// Main function that generated the passwords and returns them
|
||||
func main() {
|
||||
// Log config
|
||||
log.SetFlags(log.Ltime | log.Ldate | log.Lshortfile)
|
||||
|
||||
// Read and parse flags
|
||||
flag.Usage = func() { _, _ = fmt.Fprintf(os.Stderr, "%s\n", usage) }
|
||||
var config = parseFlags()
|
||||
|
||||
// Show version and exit
|
||||
|
|
Loading…
Reference in a new issue