Skip to content

Commit

Permalink
Update CLI API calls to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tvolkert committed Dec 6, 2019
1 parent 5f9fe4a commit 36bbc05
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions dashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ func main() {
app.Run(os.Args)
}

func commands() []cli.Command {
return []cli.Command{
func commands() []*cli.Command {
return []*cli.Command{
{
Name: "build",
Usage: "build a doc set",
Action: build,
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "source, s",
Usage: "The path to the HTML files this will ingest. (Default: ./ )",
},
cli.StringFlag{
&cli.StringFlag{
Name: "config, f",
Usage: "The path to the JSON configuration file.",
},
Expand All @@ -116,23 +116,23 @@ func commands() []cli.Command {
Usage: "update a doc set",
Action: update,
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "source, s",
Usage: "The path to the HTML files this will ingest. (Default: ./ )",
},
cli.StringFlag{
&cli.StringFlag{
Name: "config, f",
Usage: "The path to the JSON configuration file.",
},
},
},
{
Name: "init",
ShortName: "create",
Aliases: []string{"create"},
Usage: "create a new template for building documentation",
Action: create,
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "config, f",
Usage: "The path to the JSON configuration file.",
},
Expand All @@ -141,9 +141,12 @@ func commands() []cli.Command {
{
Name: "version",
Usage: "Print version and exit.",
Action: func(c *cli.Context) { fmt.Println(version) },
Action: func(c *cli.Context) error {
fmt.Println(version)
return nil
},
Flags: []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "config, f",
Usage: "The path to the JSON configuration file.",
},
Expand All @@ -152,7 +155,7 @@ func commands() []cli.Command {
}
}

func create(c *cli.Context) {
func create(c *cli.Context) error {
f := c.String("config")
if len(f) == 0 {
f = "dashing.json"
Expand All @@ -177,10 +180,10 @@ func create(c *cli.Context) {
os.Exit(1)
}
fmt.Printf("You may now edit %s\n", f)

return nil
}

func build(c *cli.Context) {
func build(c *cli.Context) error {
var dashing Dashing

source_depth := 0
Expand Down Expand Up @@ -225,13 +228,14 @@ func build(c *cli.Context) {
db, err := initDB(name, true)
if err != nil {
fmt.Printf("Failed to create database: %s\n", err)
return
return nil
}
defer db.Close()
texasRanger(source, source_depth, name, dashing, db)
return nil
}

func update(c *cli.Context) {
func update(c *cli.Context) error {
var dashing Dashing

source_depth := 0
Expand Down Expand Up @@ -276,10 +280,11 @@ func update(c *cli.Context) {
db, err := initDB(name, false)
if err != nil {
fmt.Printf("Failed to create database: %s\n", err)
return
return nil
}
defer db.Close()
texasRanger(source, source_depth, name, dashing, db)
return nil
}

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

0 comments on commit 36bbc05

Please sign in to comment.