-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.go
46 lines (41 loc) · 934 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"os"
"github.com/athul/shelby/mods"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Usage = "The Prompt with Wings"
app.Commands = []cli.Command{
sbInit,
sbInfo,
}
app.Run(os.Args)
}
var sbInit = cli.Command{
Name: "init",
Usage: "Initialize the Shell",
Description: `Put 'eval "$(shelby init <shell>)"' in your ~/.profile or ~/.bashrc or ~/.zshrc`,
Action: func(ctx *cli.Context) error {
if ctx.NArg() == 1 {
script := mods.UseShell(ctx.Args().First())
if script != "" {
os.Stdout.Write([]byte(script))
} else {
os.Stderr.Write([]byte("Error.....\n"))
os.Exit(1)
}
}
return nil
},
}
var sbInfo = cli.Command{
Name: "info",
Usage: "Print directory info",
Description: "Print directory and other mods info in a line",
Action: func(ctx *cli.Context) error {
os.Stdout.Write([]byte(mods.Info()))
return nil
},
}