Update CLI API calls to 2.0 · technosophos/dashing@36bbc05

@@ -94,18 +94,18 @@ func main() {

9494

app.Run(os.Args)

9595

}

969697-

func commands() []cli.Command {

98-

return []cli.Command{

97+

func commands() []*cli.Command {

98+

return []*cli.Command{

9999

{

100100

Name: "build",

101101

Usage: "build a doc set",

102102

Action: build,

103103

Flags: []cli.Flag{

104-

cli.StringFlag{

104+

&cli.StringFlag{

105105

Name: "source, s",

106106

Usage: "The path to the HTML files this will ingest. (Default: ./ )",

107107

},

108-

cli.StringFlag{

108+

&cli.StringFlag{

109109

Name: "config, f",

110110

Usage: "The path to the JSON configuration file.",

111111

},

@@ -116,23 +116,23 @@ func commands() []cli.Command {

116116

Usage: "update a doc set",

117117

Action: update,

118118

Flags: []cli.Flag{

119-

cli.StringFlag{

119+

&cli.StringFlag{

120120

Name: "source, s",

121121

Usage: "The path to the HTML files this will ingest. (Default: ./ )",

122122

},

123-

cli.StringFlag{

123+

&cli.StringFlag{

124124

Name: "config, f",

125125

Usage: "The path to the JSON configuration file.",

126126

},

127127

},

128128

},

129129

{

130130

Name: "init",

131-

ShortName: "create",

131+

Aliases: []string{"create"},

132132

Usage: "create a new template for building documentation",

133133

Action: create,

134134

Flags: []cli.Flag{

135-

cli.StringFlag{

135+

&cli.StringFlag{

136136

Name: "config, f",

137137

Usage: "The path to the JSON configuration file.",

138138

},

@@ -141,9 +141,12 @@ func commands() []cli.Command {

141141

{

142142

Name: "version",

143143

Usage: "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+

},

145148

Flags: []cli.Flag{

146-

cli.StringFlag{

149+

&cli.StringFlag{

147150

Name: "config, f",

148151

Usage: "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 {

156159

f := c.String("config")

157160

if len(f) == 0 {

158161

f = "dashing.json"

@@ -177,10 +180,10 @@ func create(c *cli.Context) {

177180

os.Exit(1)

178181

}

179182

fmt.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 {

184187

var dashing Dashing

185188186189

source_depth := 0

@@ -225,13 +228,14 @@ func build(c *cli.Context) {

225228

db, err := initDB(name, true)

226229

if err != nil {

227230

fmt.Printf("Failed to create database: %s\n", err)

228-

return

231+

return nil

229232

}

230233

defer db.Close()

231234

texasRanger(source, source_depth, name, dashing, db)

235+

return nil

232236

}

233237234-

func update(c *cli.Context) {

238+

func update(c *cli.Context) error {

235239

var dashing Dashing

236240237241

source_depth := 0

@@ -276,10 +280,11 @@ func update(c *cli.Context) {

276280

db, err := initDB(name, false)

277281

if err != nil {

278282

fmt.Printf("Failed to create database: %s\n", err)

279-

return

283+

return nil

280284

}

281285

defer db.Close()

282286

texasRanger(source, source_depth, name, dashing, db)

287+

return nil

283288

}

284289285290

func decodeSingleTransform(val map[string]interface{}) (*Transform, error) {