-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config file support to generate options (#33)
- Loading branch information
1 parent
8389e36
commit a2b6c17
Showing
6 changed files
with
235 additions
and
24 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package cmd | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/sylviamoss/diceware-cli/diceware" | ||
) | ||
|
||
func init() { | ||
dictionaryCmd.Flags().BoolVar(&dictionary.AddLang, "add-lang", false, "add new config language") | ||
dictionaryCmd.Flags().StringVar(&dictionary.Source, "source", "", "dictionary source file") | ||
dictionaryCmd.Flags().StringVar(&dictionary.Name, "name", "", "language name") | ||
rootCmd.AddCommand(dictionaryCmd) | ||
} | ||
|
||
var ( | ||
dictionary diceware.Dictionary | ||
|
||
dictionaryCmd = &cobra.Command{ | ||
Use: "dictionary", | ||
Short: "Manages the diceware words dictionary.", | ||
Long: `Manages the diceware words dictionary. Allows adding a new language dictionary.`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := dictionary.Configure(); err != nil { | ||
errorMsg := fmt.Sprintf("Ops...something went wrong: %s", err.Error()) | ||
return errors.New(errorMsg) | ||
} | ||
return nil | ||
}, | ||
} | ||
) |
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