initial commit (second try)
This commit is contained in:
parent
a62cf65376
commit
ed3c0eae14
7 changed files with 656 additions and 0 deletions
99
main.go
Normal file
99
main.go
Normal file
|
@ -0,0 +1,99 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "hako",
|
||||
Short: "Docker container management for Claude Code",
|
||||
Long: "A tool that manages Docker containers providing sandboxed environments for Claude Code",
|
||||
}
|
||||
|
||||
var initCmd = &cobra.Command{
|
||||
Use: "init [language]",
|
||||
Short: "Initialize Docker images",
|
||||
Long: "Build base Docker image or language-specific variants",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var lang string
|
||||
if len(args) > 0 {
|
||||
lang = args[0]
|
||||
}
|
||||
if err := initCommand(lang); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var upCmd = &cobra.Command{
|
||||
Use: "up <language>",
|
||||
Short: "Start and enter a container",
|
||||
Long: "Create or start a container for the current project and drop into shell",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if err := upCommand(args[0]); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var downCmd = &cobra.Command{
|
||||
Use: "down [container]",
|
||||
Short: "Stop a container",
|
||||
Long: "Stop and remove a container",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var container string
|
||||
if len(args) > 0 {
|
||||
container = args[0]
|
||||
}
|
||||
if err := downCommand(container); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var psCmd = &cobra.Command{
|
||||
Use: "ps",
|
||||
Short: "List running containers",
|
||||
Long: "Show all running hako containers",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if err := psCommand(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var syncCmd = &cobra.Command{
|
||||
Use: "sync",
|
||||
Short: "Sync files from container",
|
||||
Long: "Copy files from container workspace to working directory",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if err := syncCommand(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(initCmd)
|
||||
rootCmd.AddCommand(upCmd)
|
||||
rootCmd.AddCommand(downCmd)
|
||||
rootCmd.AddCommand(psCmd)
|
||||
rootCmd.AddCommand(syncCmd)
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue