Menu ▾ ▴

#15 [Feature]: Add directory-scoped CLI environment setup

open
nobody
2026-09-12
2026-09-11
Anonymous
No

Originally created by: thomijasir
Originally owned by: thomijasir

Feature description

Add directory-scoped environment selection so a repository can remember which Dopbase environment its commands should use.

Current behavior

The client configuration stores one active server and one server-wide default environment. Commands run from different repositories cannot have different defaults.

Why we need this

Developers often work across several services or a monorepo. Repeating project/environment on every command is noisy, while changing the server-wide default can make a command target the wrong environment.

Proposed CLI interface

  • dopbase setup [ENVIRONMENT] [--scope <DIR>] [--no-interactive]
  • dopbase configure
  • dopbase configure --all
  • dopbase configure debug
  • dopbase configure unset [--scope <DIR>]

Expected behavior

  • setup uses the current directory when --scope is omitted.
  • When no environment is supplied in a terminal, show a searchable list of project/environment choices.
  • --no-interactive requires an explicit environment and never prompts.
  • Store the canonical absolute scope path, active server URL, and immutable environment ID in the private client configuration.
  • Resolve run environments in this order: positional argument, DOPBASE_ENV, nearest parent-directory scope, server-wide default.
  • Keep scopes for other servers but ignore them until that server becomes active again.
  • Read version 1 client configuration and write version 2 when the first scope is saved.

Security and compatibility

  • Do not create a configuration file inside the application repository.
  • Do not store credentials or secret values in a scope entry.
  • Keep the client configuration permissions private.

Out of scope

  • Changing the server API or environment data model.
  • Storing a team-shared environment mapping in source control.

Acceptance criteria

  • [ ] A user can run dopbase setup storefront/development and omit the environment from later dopbase run calls in that directory.
  • [ ] The nearest matching parent scope wins in nested directories.
  • [ ] Explicit arguments and DOPBASE_ENV override a saved scope.
  • [ ] Non-interactive setup fails with a clear error when the environment is missing.
  • [ ] Version 1 configuration continues to load without manual migration.
  • [ ] Human and --json output show which scope and source are active.

Test scenarios

  • Add parser and configuration tests under app/tests/cli/.
  • Cover parent selection, unrelated directories, server isolation, deleted directories, precedence, and version migration.

Documentation

Document setup, resolution precedence, monorepo examples, configuration storage, and how to remove a scope.

Dependencies

Uses the existing environment list and resolution endpoints. No server change is required.

Related

Tickets: #53

Discussion

  • Anonymous

    Anonymous - 2026-09-11
     
  • Anonymous

    Anonymous - 2026-09-12

    Originally posted by: thomijasir

    Deferred for now. Directory scopes would solve a real convenience problem, but they would add another environment selection mechanism beside the explicit environment argument, DOPBASE_ENV, and the saved default. This expands the CLI surface, resolution rules, configuration migration, diagnostics, and documentation.

    Dopbase prefers one clear, documented way to complete each task. We will revisit this proposal if repeated environment arguments become a larger problem than the complexity introduced by directory scopes.

     

Log in to post a comment.