From f37548b56b96c7cb93f4b035c08cd075c044af22 Mon Sep 17 00:00:00 2001 From: ruinivist Date: Mon, 16 Mar 2026 22:04:02 +0000 Subject: [PATCH] feat: add miro record as mkdir -p --- cmd/record.go | 25 +++++++++++++++++++++++++ cmd/root.go | 2 ++ internal/miro/record.go | 22 ++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 cmd/record.go create mode 100644 internal/miro/record.go diff --git a/cmd/record.go b/cmd/record.go new file mode 100644 index 0000000..c4b20ab --- /dev/null +++ b/cmd/record.go @@ -0,0 +1,25 @@ +package cmd + +import ( + "path/filepath" + + "miro/internal/miro" + "miro/internal/output" +) + +func runRecord(args []string) int { + if len(args) != 1 { + output.Println("record requires exactly one path") + return 1 + } + + path := filepath.Clean(args[0]) + createdPath, err := miro.Record(path) + if err != nil { + output.Printf("%v\n", err) + return 1 + } + + output.Println(createdPath) + return 0 +} diff --git a/cmd/root.go b/cmd/root.go index bbddbae..bb86d74 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,6 +12,8 @@ func Run(args []string) int { switch args[0] { case "init": return runInit(args[1:]) + case "record": + return runRecord(args[1:]) default: output.Printf("unknown command: %s\n", args[0]) return 1 diff --git a/internal/miro/record.go b/internal/miro/record.go new file mode 100644 index 0000000..f1e1817 --- /dev/null +++ b/internal/miro/record.go @@ -0,0 +1,22 @@ +package miro + +import ( + "fmt" + "os" + "path/filepath" +) + +// Record creates the requested directory path under the resolved test directory. +func Record(path string) (string, error) { + testDir, err := ResolveTestDir() + if err != nil { + return "", fmt.Errorf("failed to resolve test directory: %v", err) + } + + target := filepath.Join(testDir, path) + if err := os.MkdirAll(target, 0o755); err != nil { + return "", err + } + + return target, nil +}