Update CLI API calls to 2.0 · technosophos/dashing@36bbc05
@@ -94,18 +94,18 @@ func main() {
9494app.Run(os.Args)
9595}
969697-func commands() []cli.Command {
98-return []cli.Command{
97+func commands() []*cli.Command {
98+return []*cli.Command{
9999 {
100100Name: "build",
101101Usage: "build a doc set",
102102Action: build,
103103Flags: []cli.Flag{
104- cli.StringFlag{
104+&cli.StringFlag{
105105Name: "source, s",
106106Usage: "The path to the HTML files this will ingest. (Default: ./ )",
107107 },
108- cli.StringFlag{
108+&cli.StringFlag{
109109Name: "config, f",
110110Usage: "The path to the JSON configuration file.",
111111 },
@@ -116,23 +116,23 @@ func commands() []cli.Command {
116116Usage: "update a doc set",
117117Action: update,
118118Flags: []cli.Flag{
119- cli.StringFlag{
119+&cli.StringFlag{
120120Name: "source, s",
121121Usage: "The path to the HTML files this will ingest. (Default: ./ )",
122122 },
123- cli.StringFlag{
123+&cli.StringFlag{
124124Name: "config, f",
125125Usage: "The path to the JSON configuration file.",
126126 },
127127 },
128128 },
129129 {
130130Name: "init",
131-ShortName: "create",
131+Aliases: []string{"create"},
132132Usage: "create a new template for building documentation",
133133Action: create,
134134Flags: []cli.Flag{
135- cli.StringFlag{
135+&cli.StringFlag{
136136Name: "config, f",
137137Usage: "The path to the JSON configuration file.",
138138 },
@@ -141,9 +141,12 @@ func commands() []cli.Command {
141141 {
142142Name: "version",
143143Usage: "Print version and exit.",
144-Action: func(c *cli.Context) { fmt.Println(version) },
144+Action: func(c *cli.Context) error {
145+fmt.Println(version)
146+return nil
147+ },
145148Flags: []cli.Flag{
146- cli.StringFlag{
149+&cli.StringFlag{
147150Name: "config, f",
148151Usage: "The path to the JSON configuration file.",
149152 },
@@ -152,7 +155,7 @@ func commands() []cli.Command {
152155 }
153156}
154157155-func create(c *cli.Context) {
158+func create(c *cli.Context) error {
156159f := c.String("config")
157160if len(f) == 0 {
158161f = "dashing.json"
@@ -177,10 +180,10 @@ func create(c *cli.Context) {
177180os.Exit(1)
178181 }
179182fmt.Printf("You may now edit %s\n", f)
180-183+ return nil
181184}
182185183-func build(c *cli.Context) {
186+func build(c *cli.Context) error {
184187var dashing Dashing
185188186189source_depth := 0
@@ -225,13 +228,14 @@ func build(c *cli.Context) {
225228db, err := initDB(name, true)
226229if err != nil {
227230fmt.Printf("Failed to create database: %s\n", err)
228-return
231+return nil
229232 }
230233defer db.Close()
231234texasRanger(source, source_depth, name, dashing, db)
235+return nil
232236}
233237234-func update(c *cli.Context) {
238+func update(c *cli.Context) error {
235239var dashing Dashing
236240237241source_depth := 0
@@ -276,10 +280,11 @@ func update(c *cli.Context) {
276280db, err := initDB(name, false)
277281if err != nil {
278282fmt.Printf("Failed to create database: %s\n", err)
279-return
283+return nil
280284 }
281285defer db.Close()
282286texasRanger(source, source_depth, name, dashing, db)
287+return nil
283288}
284289285290func decodeSingleTransform(val map[string]interface{}) (*Transform, error) {