feat: add miro record as mkdir -p
This commit is contained in:
@@ -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
|
||||||
|
}
|
||||||
@@ -12,6 +12,8 @@ func Run(args []string) int {
|
|||||||
switch args[0] {
|
switch args[0] {
|
||||||
case "init":
|
case "init":
|
||||||
return runInit(args[1:])
|
return runInit(args[1:])
|
||||||
|
case "record":
|
||||||
|
return runRecord(args[1:])
|
||||||
default:
|
default:
|
||||||
output.Printf("unknown command: %s\n", args[0])
|
output.Printf("unknown command: %s\n", args[0])
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user