Skip to content

Commit

Permalink
✨ Add versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
CryogenicPlanet committed Jan 14, 2022
1 parent b4093b1 commit 10bcaaa
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
36 changes: 34 additions & 2 deletions cli.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package main

import (
"fmt"
"internal/commands"

"github.com/urfave/cli/v2"
)

var (
version = "dev"
commit = "none"
date = "unknown"
builtBy = "unknown"
)

func SetupCliApp() (cli.App, error) {

cliCommands := []*cli.Command{
Expand Down Expand Up @@ -47,8 +55,14 @@ func SetupCliApp() (cli.App, error) {
{
Name: "prettier",
Usage: "Will run pretty-quick",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "all",
Usage: "Will prettify all files instead of staged files",
},
},
Action: func(c *cli.Context) error {
return commands.HandlePrettierCommand()
return commands.HandlePrettierCommand(c.Bool("all"))
},
},
{
Expand All @@ -64,6 +78,15 @@ func SetupCliApp() (cli.App, error) {
return commands.HandleLintCommand(c.Bool("fix"))
},
},
{
Name: "version",
Usage: "Version of cli",
Aliases: []string{"v"},
Action: func(c *cli.Context) error {
fmt.Printf("tsdev %s, commit %s, built at %s by %s", version, commit, date, builtBy)
return nil
},
},
}

app := &cli.App{
Expand All @@ -74,13 +97,22 @@ func SetupCliApp() (cli.App, error) {
ArgsUsage: "Run a .ts file with zero config directly",
Action: func(c *cli.Context) error {

return commands.HandleDefault(c.Bool("watch"), c.Args().Slice())
if c.Bool("version") {
fmt.Printf("tsdev %s, commit %s, built at %s by %s", version, commit, date, builtBy)
return nil
} else {
return commands.HandleDefault(c.Bool("watch"), c.Args().Slice())
}
},
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "watch",
Usage: "Run in watch mode",
},
&cli.BoolFlag{
Name: "version",
Aliases: []string{"v"},
},
},
}

Expand Down
8 changes: 0 additions & 8 deletions internal/commands/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@ func createDir(name string) error {
return nil
}

// Will clone skeleton template
func cloneTemplate(name string) error {

// Download templates from releases and unzip them

return nil
}

// Will generate package json
func generatePackageJson(name string) {

Expand Down
11 changes: 10 additions & 1 deletion internal/commands/prettier.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ import (
"os"
)

func HandlePrettierCommand() error {
func handlePrettyAll() error {

return nil
}

func HandlePrettierCommand(allFlag bool) error {

if allFlag {
return handlePrettyAll()
}

if _, err := os.Stat(types.PRETTY_QUICK_PATH); errors.Is(err, os.ErrNotExist) {

Expand Down

0 comments on commit 10bcaaa

Please sign in to comment.