MCPcopy Create free account
hub / github.com/Facets-cloud/flow / showProjectCmd

Function showProjectCmd

internal/app/show.go:97–154  ·  view source on GitHub ↗

showProjectCmd implements `flow show project [ ]`. With no argument, falls back to the project of the task bound to the current Claude session.

(args []string)

Source from the content-addressed store, hash-verified

95// argument, falls back to the project of the task bound to the
96// current Claude session.
97func showProjectCmd(args []string) int {
98 fs := flagSet("show project")
99 if err := fs.Parse(args); err != nil {
100 return 2
101 }
102 ref := ""
103 if fs.NArg() > 0 {
104 ref = fs.Arg(0)
105 }
106
107 dbPath, err := flowDBPath()
108 if err != nil {
109 fmt.Fprintf(os.Stderr, "error: %v\n", err)
110 return 1
111 }
112 db, err := flowdb.OpenDB(dbPath)
113 if err != nil {
114 fmt.Fprintf(os.Stderr, "error: open db: %v\n", err)
115 return 1
116 }
117 defer db.Close()
118
119 if ref == "" {
120 // Reverse-lookup: find the task bound to this session, then its project.
121 bound, lookupErr := currentSessionTask(db)
122 if lookupErr != nil {
123 if isNoBindingErr(lookupErr) {
124 if currentSessionID() == "" {
125 fmt.Fprintln(os.Stderr, "error: no project ref given and not running inside a Claude session ($CLAUDE_CODE_SESSION_ID unset)")
126 } else {
127 fmt.Fprintln(os.Stderr, "error: no project ref given and this Claude session is not bound to a task")
128 }
129 return 1
130 }
131 fmt.Fprintf(os.Stderr, "error: lookup task by session: %v\n", lookupErr)
132 return 1
133 }
134 if !bound.ProjectSlug.Valid || bound.ProjectSlug.String == "" {
135 fmt.Fprintf(os.Stderr, "error: bound task %q is floating (no project)\n", bound.Slug)
136 return 1
137 }
138 ref = bound.ProjectSlug.String
139 }
140
141 p, err := resolveProjectRef(db, ref)
142 if err != nil {
143 fmt.Fprintf(os.Stderr, "error: %v\n", err)
144 return 1
145 }
146
147 root, err := flowRoot()
148 if err != nil {
149 fmt.Fprintf(os.Stderr, "error: %v\n", err)
150 return 1
151 }
152 printProjectMetadata(db, p, root)
153 return 0
154}

Callers 1

cmdShowFunction · 0.85

Calls 9

OpenDBFunction · 0.92
flagSetFunction · 0.85
flowDBPathFunction · 0.85
currentSessionTaskFunction · 0.85
isNoBindingErrFunction · 0.85
currentSessionIDFunction · 0.85
resolveProjectRefFunction · 0.85
flowRootFunction · 0.85
printProjectMetadataFunction · 0.85

Tested by

no test coverage detected