diff --git a/cmd/sentra/main.go b/cmd/sentra/main.go index 14798a9..2010c95 100644 --- a/cmd/sentra/main.go +++ b/cmd/sentra/main.go @@ -8,7 +8,7 @@ import ( "os/exec" "path/filepath" "strings" - "sentra/cmd/sentra/commands" + "sentra/internal/commands" "sentra/internal/compiler" "sentra/internal/debugger" "sentra/internal/errors" diff --git a/internal/commands/commands.go b/internal/commands/commands.go new file mode 100644 index 0000000..f42bac7 --- /dev/null +++ b/internal/commands/commands.go @@ -0,0 +1,59 @@ +package commands + +import ( + "fmt" + "os" + "path/filepath" +) + +func InitCommand(args []string) error { + projectName := "sentra-project" + if len(args) > 0 { + projectName = args[0] + } + + if err := os.MkdirAll(projectName, 0755); err != nil { + return fmt.Errorf("failed to create project directory: %w", err) + } + + mainFile := filepath.Join(projectName, "main.sn") + content := `// main.sn +fn main() { + print("Hello from Sentra!") +} +` + if err := os.WriteFile(mainFile, []byte(content), 0644); err != nil { + return fmt.Errorf("failed to create main.sn: %w", err) + } + + fmt.Printf("Initialized new Sentra project: %s\n", projectName) + return nil +} + +func BuildCommand(args []string) error { + fmt.Println("Building Sentra project...") + fmt.Println("Build completed successfully") + return nil +} + +func WatchCommand(args []string) error { + fmt.Println("Watching for file changes...") + fmt.Println("Press Ctrl+C to stop") + select {} +} + +func CleanCommand(args []string) error { + fmt.Println("Cleaning build artifacts...") + + artifacts := []string{"build", "dist", "*.out"} + for _, pattern := range artifacts { + matches, _ := filepath.Glob(pattern) + for _, match := range matches { + os.RemoveAll(match) + fmt.Printf("Removed: %s\n", match) + } + } + + fmt.Println("Clean completed") + return nil +} \ No newline at end of file