Skip to content

Commit 5128a33

Browse files
first pass at setting up the cli (#1)
* first pass at setting up the cli * let the caller supply a local git repo
1 parent 216e198 commit 5128a33

File tree

946 files changed

+403207
-26
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

946 files changed

+403207
-26
lines changed

cmd/commands/root.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package commands
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/spf13/cobra"
8+
)
9+
10+
var cfgFile string
11+
12+
// rootCmd represents the base command when called without any subcommands
13+
var rootCmd = &cobra.Command{
14+
Use: "tickgit",
15+
Short: "Tickets as config",
16+
Long: `tickgit is a tool for helping you manage tickets and todos in your codebase, as a part of your git history`,
17+
Run: func(cmd *cobra.Command, args []string) {},
18+
}
19+
20+
// Execute adds all child commands to the root command and sets flags appropriately.
21+
func Execute() {
22+
if err := rootCmd.Execute(); err != nil {
23+
fmt.Println(err)
24+
os.Exit(1)
25+
}
26+
}
27+
28+
func init() {
29+
// Here you will define your flags and configuration settings.
30+
// Cobra supports persistent flags, which, if defined here,
31+
// will be global for your application.
32+
33+
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.tickgit.yaml)")
34+
35+
// Cobra also supports local flags, which will only run
36+
// when this action is called directly.
37+
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
38+
}

cmd/commands/status.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package commands
2+
3+
import (
4+
"os"
5+
"path/filepath"
6+
7+
"github.com/augmentable-dev/tickgit"
8+
"github.com/spf13/cobra"
9+
"gopkg.in/src-d/go-git.v4"
10+
)
11+
12+
func init() {
13+
rootCmd.AddCommand(versionCmd)
14+
}
15+
16+
func handleError(err error) {
17+
if err != nil {
18+
panic(err)
19+
}
20+
}
21+
22+
var versionCmd = &cobra.Command{
23+
Use: "status",
24+
Short: "Print a status report of the current directory",
25+
Long: ``,
26+
Args: cobra.MaximumNArgs(1),
27+
Run: func(cmd *cobra.Command, args []string) {
28+
cwd, err := os.Getwd()
29+
handleError(err)
30+
31+
dir := cwd
32+
if len(args) == 1 {
33+
dir, err = filepath.Rel(cwd, args[0])
34+
handleError(err)
35+
}
36+
37+
r, err := git.PlainOpen(dir)
38+
handleError(err)
39+
40+
ref, err := r.Head()
41+
handleError(err)
42+
43+
commit, err := r.CommitObject(ref.Hash())
44+
handleError(err)
45+
46+
err = tickgit.WriteStatus(commit, os.Stdout)
47+
handleError(err)
48+
},
49+
}

cmd/main.go

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,9 @@
11
package main
22

33
import (
4-
"os"
5-
6-
"github.com/augmentable-dev/tickgit"
7-
"gopkg.in/src-d/go-git.v4"
8-
"gopkg.in/src-d/go-git.v4/storage/memory"
4+
"github.com/augmentable-dev/tickgit/cmd/commands"
95
)
106

11-
func handleError(err error) {
12-
if err != nil {
13-
panic(err)
14-
}
15-
}
16-
177
func main() {
18-
r, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
19-
URL: "https://github.com/augmentable-dev/tickgit",
20-
})
21-
handleError(err)
22-
23-
ref, err := r.Head()
24-
handleError(err)
25-
26-
commit, err := r.CommitObject(ref.Hash())
27-
handleError(err)
28-
29-
err = tickgit.WriteStatus(commit, os.Stdout)
30-
handleError(err)
8+
commands.Execute()
319
}

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ require (
66
github.com/hashicorp/hcl/v2 v2.0.0
77
github.com/hashicorp/hcl2 v0.0.0-20191002203319-fb75b3253c80 // indirect
88
github.com/magiconair/properties v1.8.1 // indirect
9+
github.com/mitchellh/go-homedir v1.1.0
910
github.com/pelletier/go-toml v1.5.0 // indirect
1011
github.com/spf13/afero v1.2.2 // indirect
11-
github.com/spf13/cobra v0.0.5 // indirect
12+
github.com/spf13/cobra v0.0.5
1213
github.com/spf13/jwalterweatherman v1.1.0 // indirect
1314
github.com/spf13/pflag v1.0.5 // indirect
14-
github.com/spf13/viper v1.4.0 // indirect
15+
github.com/spf13/viper v1.4.0
1516
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 // indirect
1617
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
1718
gopkg.in/src-d/go-billy.v4 v4.3.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ github.com/pelletier/go-toml v1.5.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t
112112
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
113113
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
114114
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
115+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
115116
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
116117
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
117118
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
@@ -156,6 +157,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
156157
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
157158
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
158159
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
160+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
159161
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
160162
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
161163
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=

vendor/github.com/agext/levenshtein/.gitignore 2

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/agext/levenshtein/.travis 2.yml

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/agext/levenshtein/DCO 2

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)