### Install graphql-client CLI Source: https://github.com/railwayapp/cli/blob/master/CONTRIBUTING.md Install the graphql-client CLI tool using cargo. This is a prerequisite for generating the schema. ```sh cargo install graphql_client_cli ``` -------------------------------- ### Command Registration Macro Examples Source: https://github.com/railwayapp/cli/blob/master/_autodocs/commands-reference.md Provides concrete examples of using the `commands!` macro with various configurations, including single commands, commands with aliases, and commands with custom names. ```rust commands!( add, dev(develop), // 'railway dev' or 'railway develop' environment(env), // 'railway environment' or 'railway env' run(local), // 'railway run' or 'railway local' sandbox(sandboxes, sbx), // 'railway sandbox', 'railway sandboxes', 'railway sbx' tcp_proxy as "tcp-proxy", // 'railway tcp-proxy' (not 'tcp_proxy') variable(variables, vars, var), // Multiple aliases ); ``` -------------------------------- ### install_method Module Source: https://github.com/railwayapp/cli/blob/master/_autodocs/api-reference/utilities.md Detects how the CLI was installed and provides methods to check update capabilities. ```APIDOC ## InstallMethod::detect() -> Self ### Description Auto-detects the installation method of the CLI from the current environment. It checks environment variables, binary paths, and package manager metadata. ### Returns - `InstallMethod` - The detected installation method (e.g., `Npm`, `Homebrew`, `Prebuilt`, `Curl`, `Unknown`). ### Example ```rust let method = InstallMethod::detect(); match method { InstallMethod::Npm => println!("Installed via npm"), InstallMethod::Homebrew => println!("Installed via brew"), _ => println!("Other installation method"), } ``` ``` ```APIDOC ## InstallMethod::can_self_update(&self) -> bool ### Description Checks if the current installation method supports self-updates. This is typically true for methods like `curl` or pre-built binaries. ### Returns - `bool` - `true` if self-updates are supported, `false` otherwise. ``` ```APIDOC ## InstallMethod::can_write_binary(&self) -> bool ### Description Determines if the CLI binary location is writable for the current user, which is necessary for self-updates. ### Returns - `bool` - `true` if the binary location is writable, `false` otherwise. ``` ```APIDOC ## InstallMethod::can_auto_run_package_manager(&self) -> bool ### Description Checks if the package manager associated with the installation method can be automatically run for updates (e.g., npm, brew). ### Returns - `bool` - `true` if the package manager can be auto-run, `false` otherwise. ``` -------------------------------- ### Manual CLI Commands Source: https://github.com/railwayapp/cli/blob/master/_autodocs/INDEX.md Examples of manually running common CLI commands for testing purposes. ```bash cargo run -- login ``` ```bash cargo run -- link ``` ```bash cargo run -- up ``` ```bash cargo run -- logs --follow ``` -------------------------------- ### Start Development Watch Source: https://github.com/railwayapp/cli/blob/master/_autodocs/api-reference/controllers.md Starts a local development mode that watches specified file paths for changes and triggers hot-reloads. ```APIDOC ## Start Development Watch ### Description Watches local files and hot-reloads on changes. ### Method POST (inferred) ### Endpoint /develop/start (inferred) ### Parameters #### Request Body - **watch_paths** (array of strings) - Required - Paths to watch for changes. ### Response #### Success Response (200) - **message** (string) - Indicates that development mode has started. ``` -------------------------------- ### Detect CLI Installation Method Source: https://github.com/railwayapp/cli/blob/master/_autodocs/api-reference/utilities.md Auto-detects the CLI installation method by checking environment variables, binary paths, and package manager metadata. Falls back to `Unknown` if detection fails. ```rust pub enum InstallMethod { Npm, Homebrew, Scoop, Prebuilt, Curl, Unknown, } ``` ```rust let method = InstallMethod::detect(); match method { InstallMethod::Npm => println!("Installed via npm"), InstallMethod::Homebrew => println!("Installed via brew"), _ => println!("Other installation method"), } ``` -------------------------------- ### Define a Minimal Local Service Source: https://github.com/railwayapp/cli/blob/master/assets/railway-config/SKILL.md Configures a local service with build and start commands. Ensure your project has the necessary build and start scripts defined. ```typescript const web = service("web", { build: "bun run build", start: "NODE_ENV=production bun src/index.ts", }); ``` -------------------------------- ### Setup Railway Agent Support Source: https://github.com/railwayapp/cli/blob/master/README.md Configures Railway agent support, installing necessary skills and setting up the MCP server for AI coding tools. Use the '-y' flag to skip interactive prompts. ```bash railway setup agent -y ``` -------------------------------- ### Module Loading Order Example Source: https://github.com/railwayapp/cli/blob/master/_autodocs/api-reference/macros.md Illustrates the relationship between commands registered in the `commands!` macro and their corresponding module files, showing the expected structure for command implementation. ```rust commands!(login, dev, environment); // Requires these files/modules: src/commands/login.rs → pub struct Args, pub async fn command src/commands/dev.rs → pub struct Args, pub async fn command src/commands/environment/mod.rs → pub struct Args, pub async fn command ``` -------------------------------- ### Displaying Specific Command Help Source: https://github.com/railwayapp/cli/blob/master/_autodocs/api-reference/macros.md Illustrates how to get detailed help for a specific command, including its usage, options, and arguments. This is useful for understanding command parameters. ```bash $ railway deploy --help Provisions a template into your project Usage: railway deploy [OPTIONS] Options: -t, --template