Skip to main content

Module CliParse

Module CliParse 

Source
Expand description

§CliParse

Parses command-line arguments for workspace configuration.

§RESPONSIBILITIES

§Argument Parsing

  • Parse CLI arguments
  • Extract workspace file from arguments
  • Validate workspace file extension

§ARCHITECTURAL ROLE

§Position in Mountain

  • Early initialization component in Binary subsystem
  • Provides workspace configuration from CLI

§Dependencies

  • std::env: Environment argument access

§Dependents

  • Fn() main entry point: Uses parsed CLI args

§SECURITY

§Considerations

  • Validate workspace paths to prevent directory traversal
  • Ensure only .code-workspace files are processed

§PERFORMANCE

§Considerations

  • CLI parsing is fast, minimal overhead

Functions§

HasWorkspaceArgument
Check if a workspace argument was provided.
Parse
Parse CLI arguments and extract workspace path.
ParseWorkspaceFolders
Parse workspace folder paths from CLI / env with the following precedence:
ResolveRecentlyOpenedTopFolder 🔒
Read ~/.land/workspaces/RecentlyOpened.json’s top workspace entry and resolve it to a directory path. Mirrors the probe used by Binary/Build/WindowBuild.rs::BuildInitialUrl so the boot-seeded workspace folder agrees with the URL the webview actually loads. Returns None when the file is missing/malformed, the entry has no resolvable path, the path doesn’t exist on disk, or it isn’t a directory.
WalkUpToProjectRoot 🔒
Walk up from Start looking for a project-root marker (Cargo.toml, package.json, .git, pyproject.toml, go.mod, pnpm-workspace.yaml). Returns the first ancestor that owns one. Falls back to Start itself when nothing matches before the filesystem root.