# feat(trail): add --repo and --branch overrides for backend/GUI use

`2876f99`→[main](/content/gh/entireio/cli/commits/main/index.html)·

toothbrush·2w ago·6 files·+280 added/-21 removed

`entire trail` derived the repo from origin and the branch from the current
checkout, so it only worked inside a clone of the target repo. Add:

- persistent `--repo forge/owner/repo` (or a clone URL) on the trail root,
honored by show/list/update/delete/watch/finding. Rejected on the
local-clone commands (create, checkout, finding apply).
- `--branch` on show/watch/finding to select a trail by branch instead of the
current checkout. update/delete already had `--branch`. Mutually exclusive
with an explicit trail selector.

Auth is unchanged: it already keys off the API base URL's
.well-known/entire-api.json, independent of any local git repo.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

## Changes

6

- cmd/entire/cli

- Mtrail_checkout_cmd_test.go+2/-2
  
  - Mtrail_cmd.go+108/-12
  
  - Atrail_repo_flag_test.go+151
  
  - Mtrail_review_cmd.go+16/-6
  
  - Mtrail_review_cmd_test.go+1/-1
  
  - Mtrail_watch_cmd.go+2

```
41 unmodified lines

...

```

func newTrailCmd() *cobra.Command {
	var insecureHTTPAuth bool
	var repoOverride string

cmd := &cobra.Command{
		Use:    "trail",
		...
	}

// Target an explicit repository instead of the origin remote, so the trail
	// commands can drive a repo the caller is not checked out in (e.g. a GUI
	// backend). Commands that mutate the local clone (create, checkout, finding
	// apply) reject it via ensureNoTrailRepoOverride.
	cmd.PersistentFlags().StringVar(&repoOverride, "repo", 
		"Target repository as forge/owner/repo (e.g. gh/acme/app) or a clone URL; defaults to the origin remote")

cmd.AddCommand(newTrailShowCmd())
	cmd.AddCommand(newTrailListCmd())

...

```

type trailListOptions struct {
	JSON         bool
	Limit        int
	InsecureHTTP bool
	Repo string
}

func defaultTrailListOptions(insecureHTTP bool) trailListOptions {
	...
}

func newTrailShowCmd() *cobra.Command {
	var branch string
	cmd := &cobra.Command{
		Use:   "show [<trail>]",
		Short: "Show a trail",
		Long: `Show a trail.

If <trail> is omitted, shows the trail for the current branch. Otherwise,
<trail> may be a trail number, id, or branch in the current repo.`,
		...
	}

cmd.Flags().StringVar(&branch, "branch", "", "Show the trail for this branch instead of the current branch; cannot be combined with a trail selector")

return cmd 
}

...

```

func checkTrailResponse(resp *http.Response) error {
	...
}
