Skip to content

Add missing CLI arguments for find and resolve commands (with env var fallbacks) #353

@karthiknadig

Description

@karthiknadig

Summary

The JSONRPC server's configure request accepts several configuration options that are not available as CLI arguments on the find and resolve commands. These should be added as explicit --flags with corresponding PET_* environment variable fallbacks (using clap's env attribute).

Missing CLI arguments

CLI flag Env var Type Commands
--conda-executable PET_CONDA_EXECUTABLE Option<PathBuf> find
--pipenv-executable PET_PIPENV_EXECUTABLE Option<PathBuf> find
--poetry-executable PET_POETRY_EXECUTABLE Option<PathBuf> find
--environment-directories PET_ENVIRONMENT_DIRECTORIES Option<Vec<PathBuf>> find

Implementation approach

Use clap's env attribute so the CLI flag takes precedence, with the environment variable as a fallback:

/// Path to the conda/mamba executable.
#[arg(long, env = "PET_CONDA_EXECUTABLE")]
conda_executable: Option<PathBuf>,

/// Path to the pipenv executable.
#[arg(long, env = "PET_PIPENV_EXECUTABLE")]
pipenv_executable: Option<PathBuf>,

/// Path to the poetry executable.
#[arg(long, env = "PET_POETRY_EXECUTABLE")]
poetry_executable: Option<PathBuf>,

/// Additional directories where virtual environments can be found.
#[arg(long, env = "PET_ENVIRONMENT_DIRECTORIES", value_delimiter = ',')]
environment_directories: Option<Vec<PathBuf>>,

Wire these into create_config() in crates/pet/src/lib.rs so they populate the Configuration struct the same way the JSONRPC handle_configure does.

Files to modify

  • crates/pet/src/main.rs — add new args to the Find command enum variant
  • crates/pet/src/lib.rs — update FindOptions and create_config() to pass the new options through to Configuration

Notes

  • resolve only needs --cache-directory (already present). The tool-specific executables are only used during discovery (find).
  • For list-valued env vars (e.g. PET_ENVIRONMENT_DIRECTORIES), use , as the delimiter via value_delimiter = ','.
  • Consider also adding PET_CACHE_DIRECTORY and PET_SEARCH_PATHS env var fallbacks to the existing --cache-directory and search paths args for consistency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions