mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-22 13:50:49 +01:00
commit
092fa3b841
2 changed files with 55 additions and 73 deletions
|
@ -5,7 +5,8 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="fbb0c733-4aa1-4d27-87d5-c7276d8aa613" name="Default Changelist" comment="">
|
<list default="true" id="fbb0c733-4aa1-4d27-87d5-c7276d8aa613" name="Default Changelist" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/apg.go" beforeDir="false" afterPath="$PROJECT_DIR$/apg.go" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
@ -24,7 +25,7 @@
|
||||||
<component name="Git.Settings">
|
<component name="Git.Settings">
|
||||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||||
<map>
|
<map>
|
||||||
<entry key="$PROJECT_DIR$" value="dev" />
|
<entry key="$PROJECT_DIR$" value="main" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
@ -69,7 +70,27 @@
|
||||||
<recent name="C:\Users\Winni Neessen\go\src\apg.go\test" />
|
<recent name="C:\Users\Winni Neessen\go\src\apg.go\test" />
|
||||||
</key>
|
</key>
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager" selected="Go Test.Test 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">
|
<configuration name="Run Application (with excludes)" type="GoApplicationRunConfiguration" factoryName="Go Application">
|
||||||
<module name="apg.go" />
|
<module name="apg.go" />
|
||||||
<working_directory value="$PROJECT_DIR$" />
|
<working_directory value="$PROJECT_DIR$" />
|
||||||
|
@ -139,17 +160,6 @@
|
||||||
<filePath value="$PROJECT_DIR$" />
|
<filePath value="$PROJECT_DIR$" />
|
||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="BenchmarkGetRandNum in apg.go" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
|
|
||||||
<module name="apg.go" />
|
|
||||||
<working_directory value="$PROJECT_DIR$" />
|
|
||||||
<framework value="gobench" />
|
|
||||||
<kind value="PACKAGE" />
|
|
||||||
<package value="apg.go" />
|
|
||||||
<directory value="$PROJECT_DIR$" />
|
|
||||||
<filePath value="$PROJECT_DIR$" />
|
|
||||||
<pattern value="^\QBenchmarkGetRandNum\E$" />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<configuration name="Test Application" type="GoTestRunConfiguration" factoryName="Go Test">
|
<configuration name="Test Application" type="GoTestRunConfiguration" factoryName="Go Test">
|
||||||
<module name="apg.go" />
|
<module name="apg.go" />
|
||||||
<working_directory value="$PROJECT_DIR$" />
|
<working_directory value="$PROJECT_DIR$" />
|
||||||
|
@ -160,49 +170,6 @@
|
||||||
<filePath value="$PROJECT_DIR$" />
|
<filePath value="$PROJECT_DIR$" />
|
||||||
<method v="2" />
|
<method v="2" />
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="TestConvert in github.com/wneessen/apg.go" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
|
|
||||||
<module name="apg.go" />
|
|
||||||
<working_directory value="$PROJECT_DIR$" />
|
|
||||||
<framework value="gotest" />
|
|
||||||
<kind value="PACKAGE" />
|
|
||||||
<package value="github.com/wneessen/apg.go" />
|
|
||||||
<directory value="$PROJECT_DIR$" />
|
|
||||||
<filePath value="$PROJECT_DIR$" />
|
|
||||||
<pattern value="^\QTestConvert\E$" />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<configuration name="TestGetCharRange in apg.go" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
|
|
||||||
<module name="apg.go" />
|
|
||||||
<working_directory value="$PROJECT_DIR$" />
|
|
||||||
<framework value="gotest" />
|
|
||||||
<kind value="DIRECTORY" />
|
|
||||||
<package value="apg.go" />
|
|
||||||
<directory value="$PROJECT_DIR$" />
|
|
||||||
<filePath value="$PROJECT_DIR$" />
|
|
||||||
<pattern value="^\QTestGetCharRange\E$" />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<configuration name="TestGetRandNum in github.com/wneessen/apg.go (1)" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
|
|
||||||
<module name="apg.go" />
|
|
||||||
<working_directory value="$PROJECT_DIR$" />
|
|
||||||
<framework value="gotest" />
|
|
||||||
<kind value="PACKAGE" />
|
|
||||||
<package value="github.com/wneessen/apg.go" />
|
|
||||||
<directory value="$PROJECT_DIR$" />
|
|
||||||
<filePath value="$PROJECT_DIR$" />
|
|
||||||
<pattern value="^\QTestGetRandNum\E$" />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<configuration name="apg.go" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
|
|
||||||
<module name="apg.go" />
|
|
||||||
<working_directory value="$PROJECT_DIR$" />
|
|
||||||
<framework value="gotest" />
|
|
||||||
<kind value="DIRECTORY" />
|
|
||||||
<package value="apg.go" />
|
|
||||||
<directory value="$PROJECT_DIR$" />
|
|
||||||
<filePath value="$PROJECT_DIR$" />
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
<list>
|
<list>
|
||||||
<item itemvalue="Go Build.Run Application" />
|
<item itemvalue="Go Build.Run Application" />
|
||||||
<item itemvalue="Go Build.Run Application (with params)" />
|
<item itemvalue="Go Build.Run Application (with params)" />
|
||||||
|
@ -210,23 +177,11 @@
|
||||||
<item itemvalue="Go Build.Run Application (with newstyle params)" />
|
<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)" />
|
||||||
<item itemvalue="Go Build.Run Application (with newstyle params and spelling and multiple pws)" />
|
<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.Test Application" />
|
||||||
<item itemvalue="Go Test.Benchmark Application" />
|
<item itemvalue="Go Test.Benchmark Application" />
|
||||||
<item itemvalue="Go Test.TestGetRandNum in github.com/wneessen/apg.go (1)" />
|
|
||||||
<item itemvalue="Go Test.TestConvert in github.com/wneessen/apg.go" />
|
|
||||||
<item itemvalue="Go Test.BenchmarkGetRandNum in apg.go" />
|
|
||||||
<item itemvalue="Go Test.apg.go" />
|
|
||||||
<item itemvalue="Go Test.TestGetCharRange in apg.go" />
|
|
||||||
</list>
|
</list>
|
||||||
<recent_temporary>
|
|
||||||
<list>
|
|
||||||
<item itemvalue="Go Test.TestGetCharRange in apg.go" />
|
|
||||||
<item itemvalue="Go Test.apg.go" />
|
|
||||||
<item itemvalue="Go Test.BenchmarkGetRandNum in apg.go" />
|
|
||||||
<item itemvalue="Go Test.TestConvert in github.com/wneessen/apg.go" />
|
|
||||||
<item itemvalue="Go Test.TestGetRandNum in github.com/wneessen/apg.go (1)" />
|
|
||||||
</list>
|
|
||||||
</recent_temporary>
|
|
||||||
</component>
|
</component>
|
||||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
@ -271,7 +226,11 @@
|
||||||
<MESSAGE value="Tests cleanup. Used structs for tests instead of repeating code" />
|
<MESSAGE value="Tests cleanup. Used structs for tests instead of repeating code" />
|
||||||
<MESSAGE value="v0.2.7: Switched global config to it's own package" />
|
<MESSAGE value="v0.2.7: Switched global config to it's own package" />
|
||||||
<MESSAGE value="Updated .gitignore" />
|
<MESSAGE value="Updated .gitignore" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Updated .gitignore" />
|
<MESSAGE value="Removed .idea from .gitignore" />
|
||||||
|
<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>
|
||||||
<component name="VgoProject">
|
<component name="VgoProject">
|
||||||
<integration-enabled>true</integration-enabled>
|
<integration-enabled>true</integration-enabled>
|
||||||
|
|
25
apg.go
25
apg.go
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
@ -8,7 +9,7 @@ import (
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const DefaultPwLenght int = 20
|
const DefaultPwLenght int = 20
|
||||||
const VersionString string = "0.2.8"
|
const VersionString string = "0.2.9"
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
minPassLen int
|
minPassLen int
|
||||||
|
@ -28,12 +29,34 @@ type Config struct {
|
||||||
outputMode int
|
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
|
// Main function that generated the passwords and returns them
|
||||||
func main() {
|
func main() {
|
||||||
// Log config
|
// Log config
|
||||||
log.SetFlags(log.Ltime | log.Ldate | log.Lshortfile)
|
log.SetFlags(log.Ltime | log.Ldate | log.Lshortfile)
|
||||||
|
|
||||||
// Read and parse flags
|
// Read and parse flags
|
||||||
|
flag.Usage = func() { _, _ = fmt.Fprintf(os.Stderr, "%s\n", usage) }
|
||||||
var config = parseFlags()
|
var config = parseFlags()
|
||||||
|
|
||||||
// Show version and exit
|
// Show version and exit
|
||||||
|
|
Loading…
Reference in a new issue