Skip to content

Commit 45bbc6c

Browse files
committed
initial go-cat commit
1 parent 6ea0f0e commit 45bbc6c

File tree

6 files changed

+86
-0
lines changed

6 files changed

+86
-0
lines changed

cli-files/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ If you smash through this, here's some fun/tricky extensions:
146146
- Write some tests for `go-ls`
147147
- Extend `go-ls` to support some more features of the real `ls` (for example, `ls -m assets`)
148148

149+
### go-cat
150+
151+
- make sure GOPATH bin setup is correct: https://sourabhbajaj.com/mac-setup/Go/
152+
- install cobra-cli: https://github.com/spf13/cobra-cli/blob/main/README.md
153+
- make `go-cat` dir, cd in, `go mod init go-cat`
154+
- `cobra-cli init .`
155+
- look at all the files
156+
- `go install . && go-cat`
157+
149158
[go]: https://go.dev/
150159
[cat]: https://en.m.wikipedia.org/wiki/Cat_(Unix)
151160
[ls]: https://en.m.wikipedia.org/wiki/Ls

cli-files/go-cat/LICENSE

Whitespace-only changes.

cli-files/go-cat/cmd/root.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
3+
4+
*/
5+
package cmd
6+
7+
import (
8+
"os"
9+
10+
"github.com/spf13/cobra"
11+
)
12+
13+
// rootCmd represents the base command when called without any subcommands
14+
var rootCmd = &cobra.Command{
15+
Use: "go-cat",
16+
Short: "A brief description of your application",
17+
Long: `A longer description that spans multiple lines and likely contains
18+
examples and usage of using your application. For example:
19+
20+
Cobra is a CLI library for Go that empowers applications.
21+
This application is a tool to generate the needed files
22+
to quickly create a Cobra application.`,
23+
// Uncomment the following line if your bare application
24+
// has an action associated with it:
25+
// Run: func(cmd *cobra.Command, args []string) { },
26+
}
27+
28+
// Execute adds all child commands to the root command and sets flags appropriately.
29+
// This is called by main.main(). It only needs to happen once to the rootCmd.
30+
func Execute() {
31+
err := rootCmd.Execute()
32+
if err != nil {
33+
os.Exit(1)
34+
}
35+
}
36+
37+
func init() {
38+
// Here you will define your flags and configuration settings.
39+
// Cobra supports persistent flags, which, if defined here,
40+
// will be global for your application.
41+
42+
// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.go-cat.yaml)")
43+
44+
// Cobra also supports local flags, which will only run
45+
// when this action is called directly.
46+
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
47+
}

cli-files/go-cat/go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module go-cat
2+
3+
go 1.18
4+
5+
require (
6+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
7+
github.com/spf13/cobra v1.5.0 // indirect
8+
github.com/spf13/pflag v1.0.5 // indirect
9+
)

cli-files/go-cat/go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
2+
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
3+
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
4+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
5+
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
6+
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
7+
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
8+
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
9+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
10+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=

cli-files/go-cat/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
3+
4+
*/
5+
package main
6+
7+
import "go-cat/cmd"
8+
9+
func main() {
10+
cmd.Execute()
11+
}

0 commit comments

Comments
 (0)