MCPcopy Index your code
hub / github.com/nikivdev/go / runCloneAndOpen

Function runCloneAndOpen

cli/flow/main.go:1072–1108  ·  view source on GitHub ↗
(ctx *snap.Context)

Source from the content-addressed store, hash-verified

1070}
1071
1072func runCloneAndOpen(ctx *snap.Context) error {
1073 if ctx.NArgs() > 1 {
1074 fmt.Fprintf(ctx.Stderr(), "Usage: %s cloneAndOpen [github-url]\n", commandName)
1075 return fmt.Errorf("expected at most 1 argument, got %d", ctx.NArgs())
1076 }
1077
1078 var input string
1079 if ctx.NArgs() == 1 {
1080 input = strings.TrimSpace(ctx.Arg(0))
1081 if input == "" {
1082 fmt.Fprintf(ctx.Stderr(), "Usage: %s cloneAndOpen [github-url]\n", commandName)
1083 return fmt.Errorf("github url cannot be empty")
1084 }
1085 } else {
1086 safariURL, err := activeSafariURL()
1087 if err != nil {
1088 fmt.Fprintf(ctx.Stderr(), "Usage: %s cloneAndOpen [github-url]\n", commandName)
1089 return fmt.Errorf("determine Safari URL: %w", err)
1090 }
1091 input = safariURL
1092 fmt.Fprintf(ctx.Stdout(), "ℹ️ Using Safari URL %s\n", input)
1093 }
1094
1095 targetDir, err := cloneRepository(ctx, input)
1096 if err != nil {
1097 return err
1098 }
1099
1100 fmt.Fprintf(ctx.Stdout(), "✔️ Cloned to %s\n", targetDir)
1101
1102 if err := openInCursor(ctx, targetDir); err != nil {
1103 return err
1104 }
1105
1106 fmt.Fprintf(ctx.Stdout(), "✔️ Opened %s in Cursor\n", targetDir)
1107 return nil
1108}
1109
1110func runClonePR(ctx *snap.Context) error {
1111 if ctx.NArgs() != 1 {

Callers 1

mainFunction · 0.85

Calls 3

activeSafariURLFunction · 0.85
cloneRepositoryFunction · 0.85
openInCursorFunction · 0.85

Tested by

no test coverage detected