summaryrefslogtreecommitdiffstats
path: root/commands/new.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-02-05 18:41:40 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-02-05 21:18:45 +0100
commit87ca0d0cbea19dd2c0aac44dc2731e6247a82ece (patch)
tree0982fb3e77c5f2de3e8216041f0ee975806a29ae /commands/new.go
parentbd0176a5487b0d8c368a14b3f283b9029f51d619 (diff)
Clean flags
* Reduce the amount of global flags * Unexport all flag vars and commands vars * Some other minor flag cleaning
Diffstat (limited to 'commands/new.go')
-rw-r--r--commands/new.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/commands/new.go b/commands/new.go
index 8c2e4850f..73065fa94 100644
--- a/commands/new.go
+++ b/commands/new.go
@@ -30,11 +30,14 @@ import (
"github.com/spf13/viper"
)
-var siteType string
-var configFormat string
-var contentType string
-var contentFormat string
-var contentFrontMatter string
+var (
+ configFormat string
+ contentEditor string
+ contentFormat string
+ contentFrontMatter string
+ contentType string
+ siteType string
+)
func init() {
newSiteCmd.Flags().StringVarP(&configFormat, "format", "f", "toml", "config & frontmatter format")
@@ -43,8 +46,11 @@ func init() {
newCmd.Flags().StringVarP(&contentType, "kind", "k", "", "Content type to create")
newCmd.PersistentFlags().StringVarP(&Source, "source", "s", "", "filesystem path to read files relative from")
newCmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
+ newCmd.Flags().StringVar(&contentEditor, "editor", "", "edit new content with this editor, if provided")
+
newCmd.AddCommand(newSiteCmd)
newCmd.AddCommand(newThemeCmd)
+
}
var newCmd = &cobra.Command{
@@ -85,10 +91,14 @@ func NewContent(cmd *cobra.Command, args []string) error {
return err
}
- if cmd.Flags().Lookup("format").Changed {
+ if flagChanged(cmd.Flags(), "format") {
viper.Set("MetaDataFormat", configFormat)
}
+ if flagChanged(cmd.Flags(), "editor") {
+ viper.Set("NewContentEditor", contentEditor)
+ }
+
if len(args) < 1 {
return newUserError("path needs to be provided")
}