Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Better help
Browse files Browse the repository at this point in the history
  • Loading branch information
MickMake committed Jun 22, 2020
1 parent f4d5111 commit bdc7af7
Show file tree
Hide file tree
Showing 7 changed files with 731 additions and 716 deletions.
68 changes: 44 additions & 24 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 60 additions & 33 deletions cmd/commands.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cmd

import (
"github.com/newclarity/scribeHelpers/loadTools"
"github.com/newclarity/scribeHelpers/ux"
"github.com/spf13/cobra"
"github.com/wplib/deploywp/defaults"
Expand All @@ -13,47 +12,75 @@ var onlyTwice = []string{"", ""}

func init() {
rootCmd.AddCommand(buildCmd)
rootCmd.AddCommand(convertCmd)
rootCmd.AddCommand(toolsCmd)
rootCmd.AddCommand(loadCmd)
rootCmd.AddCommand(runCmd)
//rootCmd.AddCommand(toolsCmd)
//rootCmd.AddCommand(loadCmd)
//rootCmd.AddCommand(runCmd)
}


var buildCmd = &cobra.Command{
Use: loadTools.CmdBuild,
Use: "build",
Short: ux.SprintfMagenta(defaults.BinaryName) + ux.SprintfBlue(" - Build a Pantheon website."),
Long: ux.SprintfMagenta(defaults.BinaryName) + ux.SprintfBlue(" - Build a Pantheon website."),
Args: cobra.RangeArgs(1, 2),
Run: cmdBuild,
}

var toolsCmd = &cobra.Command{
Use: loadTools.CmdTools,
Short: ux.SprintfMagenta("scribe") + ux.SprintfBlue(" - Show all built-in template helpers."),
Long: ux.SprintfMagenta("scribe") + ux.SprintfBlue(" - Show all built-in template helpers."),
Run: cmdTools,
}
func cmdBuild(cmd *cobra.Command, args []string) {
state := CmdScribe.State

var convertCmd = &cobra.Command{
Use: loadTools.CmdConvert,
Short: ux.SprintfMagenta("scribe") + ux.SprintfBlue(" - Convert a template file to the resulting output file."),
Long: ux.SprintfMagenta("scribe") + ux.SprintfBlue(" - Convert a template file to the resulting output file."),
Run: cmdConvert,
}
var loadCmd = &cobra.Command{
Use: loadTools.CmdLoad,
Short: ux.SprintfMagenta("scribe") + ux.SprintfBlue(" - Load and execute a template file."),
Long: ux.SprintfMagenta("scribe") + ux.SprintfBlue(" - Load and execute a template file."),
Run: cmdLoad,
DisableFlagParsing: false,
}
var runCmd = &cobra.Command{
Use: loadTools.CmdRun,
Short: ux.SprintfMagenta("scribe") + ux.SprintfBlue(" - Execute resulting output file as a BASH script."),
Long: ux.SprintfMagenta("scribe") + ux.SprintfBlue(`Execute resulting output file as a BASH script.
You can also use this command as the start to '#!' scripts.
For example: #!/usr/bin/env scribe --json gearbox.json run
`),
Run: cmdRun,
for range onlyOnce {
CmdScribe.Chdir = true // In this mode we always change directory to the JSON file.

state = CmdScribe.ProcessArgs(cmd.Use, args)
if state.IsNotOk() {
state.PrintResponse()
break
}

state = CmdScribe.Load()
if state.IsNotOk() {
state.PrintResponse()
break
}

ux.PrintflnOk("Building website via deploywp.")
state = CmdScribe.Run()

state.PrintResponse()
ux.PrintflnBlue("\n# FINISHED")
}

CmdScribe.State = state
}


//var toolsCmd = &cobra.Command{
// Use: loadTools.CmdTools,
// Short: ux.SprintfMagenta("scribe") + ux.SprintfBlue(" - Show all built-in template helpers."),
// Long: ux.SprintfMagenta("scribe") + ux.SprintfBlue(" - Show all built-in template helpers."),
// Run: cmdTools,
//}
//
//var convertCmd = &cobra.Command{
// Use: loadTools.CmdConvert,
// Short: ux.SprintfMagenta("scribe") + ux.SprintfBlue(" - Convert a template file to the resulting output file."),
// Long: ux.SprintfMagenta("scribe") + ux.SprintfBlue(" - Convert a template file to the resulting output file."),
// Run: cmdConvert,
//}
//var loadCmd = &cobra.Command{
// Use: loadTools.CmdLoad,
// Short: ux.SprintfMagenta("scribe") + ux.SprintfBlue(" - Load and execute a template file."),
// Long: ux.SprintfMagenta("scribe") + ux.SprintfBlue(" - Load and execute a template file."),
// Run: cmdLoad,
// DisableFlagParsing: false,
//}
//var runCmd = &cobra.Command{
// Use: loadTools.CmdRun,
// Short: ux.SprintfMagenta("scribe") + ux.SprintfBlue(" - Execute resulting output file as a BASH script."),
// Long: ux.SprintfMagenta("scribe") + ux.SprintfBlue(`Execute resulting output file as a BASH script.
//You can also use this command as the start to '#!' scripts.
//For example: #!/usr/bin/env scribe --json gearbox.json run
//`),
// Run: cmdRun,
//}
Loading

0 comments on commit bdc7af7

Please sign in to comment.