Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
kkga committed Sep 7, 2021
1 parent 4275ec1 commit 9a246ff
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
3 changes: 2 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- [ ] kill cmd
- [ ] detach newly started sessions from shell (setsid?)
- [ ] edit cmd needs line:col support
- [ ] find solution to remove the timeout in Get
- [x] find solution to remove the timeout in Get
- buflist should return relative to cwd
- grep cmd?
39 changes: 30 additions & 9 deletions kks.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func main() {
attachCmd := flag.NewFlagSet("attach", flag.ExitOnError)
getCmd := flag.NewFlagSet("get", flag.ExitOnError)
killCmd := flag.NewFlagSet("kill", flag.ExitOnError)
listCmd := flag.NewFlagSet("list", flag.ExitOnError)
envCmd := flag.NewFlagSet("env", flag.ExitOnError)

sessionCmds := []*flag.FlagSet{editCmd, sendCmd, attachCmd, getCmd, killCmd}
for _, cmd := range sessionCmds {
Expand All @@ -52,18 +54,14 @@ func main() {
case "kill":
killCmd.Parse(os.Args[2:])
case "list", "l", "ls":
cmd.List()
listCmd.Parse(os.Args[2:])
case "env":
context, err := getContext()
if err != nil {
log.Fatal(err)
}
cmd.Env(context.session, context.client)
envCmd.Parse(os.Args[2:])
case "init":
fmt.Print(initStr)
default:
printHelp()
os.Exit(2)
fmt.Println("unknown command:", os.Args[1])
os.Exit(1)
}

if editCmd.Parsed() {
Expand Down Expand Up @@ -103,7 +101,6 @@ func main() {

if getCmd.Parsed() {
arg := getCmd.Arg(0)
// kakQuery := fmt.Sprintf("%%val{%s}", arg)

context, err := getContext()
if err != nil {
Expand All @@ -115,6 +112,17 @@ func main() {
log.Fatal(err)
}

// cwd, err := os.Getwd()
// if err != nil {
// log.Fatal(err)
// }
// fmt.Println(cwd)
// kakwd, err := cmd.Get("%sh{pwd}", context.session, context.client)
// if err != nil {
// log.Fatal(err)
// }
// fmt.Println(kakwd)

fmt.Println(strings.Join(out, "\n"))
}

Expand All @@ -128,6 +136,19 @@ func main() {
cmd.Send(kakCommand, context.session, context.client)
}

if listCmd.Parsed() {
cmd.List()
}

if envCmd.Parsed() {
context, err := getContext()
if err != nil {
log.Fatal(err)
}
fmt.Printf("session: %s\n", context.session)
fmt.Printf("client: %s\n", context.client)
}

}

func getContext() (*KakContext, error) {
Expand Down

0 comments on commit 9a246ff

Please sign in to comment.