Skip to content

Improve CLI project and organization discovery - #1803

Merged
ChiragAgg5k merged 2 commits into
mainfrom
feat/cli-resource-discovery
Aug 16, 2026
Merged

Improve CLI project and organization discovery#1803
ChiragAgg5k merged 2 commits into
mainfrom
feat/cli-resource-discovery

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Aug 16, 2026

Copy link
Copy Markdown
Member

Summary

  • add names, member counts, and organization metadata to list-organizations and list-projects
  • add list-projects --organization-id and restore all-organization discovery for self-hosted session logins
  • normalize OAuth, cookie, and self-hosted results into the same response shape
  • add compact tables, page counts, empty states, and contextual hints
  • suppress hints for JSON, raw, and piped output
before: projects (25) -> $id, region, repeated endpoint
after:  projects (25 of 224) -> name, id, organization, region

Live verification

Built the generated CLI and ran it against an Appwrite Cloud account with 3 organizations and 224 projects.

Organization metadata

$ appwrite list-organizations
organizations (3 of 3)
  name                   id                    members
  Refetch                6394ab479bf0a354e412  11
  Chirag's Organization  67610b8ee51f147ca943  2
  Appwrite Official      appwriteOfficials     19

Enriched projects across organizations

$ appwrite list-projects --limit 5
projects (5 of 224)
  name                      id                    organization       region
  Newsletterf sdf ksdlf k…  6394ab53c97037196912  Refetch            fra
  Refetch                   63ef1792594ff4f50de2  Refetch            fra
  Website Thumbnail         651154975c6cabe565be  Appwrite Official  fra
  Threads                   656dd556812fe2e5f4ed  Appwrite Official  fra
  Init                      659868b10fff07726b85  Appwrite Official  fra

Verified that enrichment also works for projects outside FRA:

$ appwrite list-projects --limit 5 --offset 29
projects (5 of 224)
  name                id                    organization       region
  Sydney Project      67fe9a9900181f824398  Appwrite Official  syd
  New York Project    67fe9ae60029483b7b7c  Appwrite Official  nyc
  Frankfurt Project   67fe9be3002093df458  Appwrite Official  fra
  Matej project       67fe9e9900300e0db652  Appwrite Official  syd
  New York Project 2  67fe9ef4001a5b80ce28  Appwrite Official  nyc

Organization filtering and server-side pagination

$ appwrite list-projects --organization-id appwriteOfficials --limit 2 --offset 2
projects (2 of 213)
  name                 id                 organization       region
  TechScrunch          techCrunchs        Appwrite Official  fra
  Built with Appwrite  builtWithAppwrite  Appwrite Official  fra

The three organization totals were 5, 6, and 213 projects, matching the global total of 224.

Contextual hints

Ran the generated binary under a PTY to exercise the interactive-only path:

$ appwrite list-projects --limit 2
projects (2 of 224)
  ...
♥ Hint: Showing 1–2 of 224. Next page: appwrite list-projects --limit 2 --offset 2

A filtered result suggests the matching detail command:

$ appwrite list-projects --organization-id 6394ab479bf0a354e412 --search Refetch
projects (1 of 1)
  name     id                    organization  region
  Refetch  63ef1792594ff4f50de2  Refetch       fra
♥ Hint: Project details: appwrite project get --project-id <PROJECT_ID>

An empty search provides recovery guidance:

$ appwrite list-projects --search zzqqvvxxnonesuch987654321
No projects found.
♥ Hint: Try a shorter search or remove --search.

Also verified that these hints are absent from --json, --raw, and piped output. JSON contains the normalized metadata:

{
  "$id": "63ef1792594ff4f50de2",
  "name": "Refetch",
  "organizationId": "6394ab479bf0a354e412",
  "organization": "Refetch",
  "region": "fra",
  "endpoint": "https://fra.cloud.appwrite.io/v1"
}

OSS self-hosted verification

Switched the generated CLI to an existing self-hosted session at https://oss.appwrite.org/v1 and exercised the console fallback rather than the Cloud-only OAuth2 discovery routes.

Organization and project metadata

$ appwrite list-organizations
organizations (1 of 1)
  name           id                    members
  Appwrite Labs  6a6c75b80022febbdc5f  1

$ appwrite list-projects --limit 5
projects (1 of 1)
  name                  id                    organization   region
  Appwrite Self Hosted  appwrite-self-hosted  Appwrite Labs  default

The normalized self-hosted JSON includes the configured endpoint and the same fields as Cloud:

{
  "$id": "appwrite-self-hosted",
  "name": "Appwrite Self Hosted",
  "organizationId": "6a6c75b80022febbdc5f",
  "organization": "Appwrite Labs",
  "region": "default",
  "endpoint": "https://oss.appwrite.org/v1"
}

Filtering, hints, and detail commands

$ appwrite list-projects --organization-id 6a6c75b80022febbdc5f --search "Self Hosted"
projects (1 of 1)
  name                  id                    organization   region
  Appwrite Self Hosted  appwrite-self-hosted  Appwrite Labs  default
♥ Hint: Project details: appwrite project get --project-id <PROJECT_ID>

Verified both commands suggested by the discovery output against the self-hosted session:

$ appwrite organization get --organization-id 6a6c75b80022febbdc5f
$id   : 6a6c75b80022febbdc5f
name  : Appwrite Labs
total : 1

$ appwrite project get --project-id appwrite-self-hosted
$id      : appwrite-self-hosted
name     : Appwrite Self Hosted
teamId   : 6a6c75b80022febbdc5f
region   : default
status   : active

Also verified self-hosted --json and --raw, the empty-search recovery hint, and that piping the filtered command through cat suppresses hints. The active session was switched back to Appwrite Cloud after testing.

Test plan

  • php example.php cli
  • cd examples/cli && go mod tidy && go build ./... && go vet ./... && go test ./...
  • cd examples/cli && go test -race ./internal/app ./internal/output ./internal/sdk
  • test -z "$(gofmt -l examples/cli)"
  • composer lint
  • composer lint-twig
  • composer refactor:check
  • Live Cloud checks above for metadata, filtering, pagination, regions, hints, JSON, raw, and piped output

@greptile-apps

greptile-apps Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR enriches organization and project discovery across OAuth, cookie, and self-hosted sessions while adding consistent pagination, filtering, rendering, and interactive hints.

  • Uses each discovered project’s regional endpoint when fetching project metadata.
  • Normalizes organization and project results across authentication modes.
  • Adds organization filtering, compact discovery tables, empty states, and terminal-only hints.

Confidence Score: 5/5

The PR appears safe to merge.

The previously reported cross-region enrichment failure is resolved because project metadata clients now use the discovered regional endpoint, and no blocking failure remains.

Important Files Changed

Filename Overview
templates/cli/internal/app/fallback.go.twig The prior cross-region enrichment issue is fixed by passing the discovered or region-derived endpoint into the project-scoped client.
templates/cli/internal/sdk/sdk.go.twig Adds a session-project client that uses the discovered endpoint while validating it belongs to the active login.
templates/cli/internal/cmd/services/service.go.twig Wires organization filtering and normalized list rendering into generated discovery commands.
templates/cli/internal/output/render.go Adds discovery-specific page counts and empty-state rendering without changing unrelated object rendering.
templates/cli/internal/output/collections.go Adds compact organization and project table schemas with complete identifiers and truncated descriptive labels.

Reviews (3): Last reviewed commit: "address greptile review feedback (greplo..." | Re-trigger Greptile

Comment thread templates/cli/internal/app/fallback.go.twig Outdated
@ChiragAgg5k

Copy link
Copy Markdown
Member Author

@greptile review

@ChiragAgg5k
ChiragAgg5k merged commit 97fae75 into main Aug 16, 2026
59 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the feat/cli-resource-discovery branch August 16, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant