Download codex-rs/cloud-tasks/src/cli.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 3.38 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/cloud-tasks/src/cli.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/cloud-tasks/src/cli.rs
-
curl -L -o cli.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/cloud-tasks/src/cli.rs
3.38 kB
| use clap::Args; | |
| use clap::Parser; | |
| use codex_utils_cli::CliConfigOverrides; | |
| pub struct Cli { | |
| pub config_overrides: CliConfigOverrides, | |
| pub command: Option<Command>, | |
| } | |
| pub enum Command { | |
| /// Submit a new Codex Cloud task without launching the TUI. | |
| Exec(ExecCommand), | |
| /// Show the status of a Codex Cloud task. | |
| Status(StatusCommand), | |
| /// List Codex Cloud tasks. | |
| List(ListCommand), | |
| /// Apply the diff for a Codex Cloud task locally. | |
| Apply(ApplyCommand), | |
| /// Show the unified diff for a Codex Cloud task. | |
| Diff(DiffCommand), | |
| } | |
| pub struct ExecCommand { | |
| /// Task prompt to run in Codex Cloud. | |
| pub query: Option<String>, | |
| /// Target environment identifier (see `codex cloud` to browse). | |
| pub environment: String, | |
| /// Number of assistant attempts (best-of-N). | |
| pub attempts: usize, | |
| /// Git branch to run in Codex Cloud (defaults to current branch). | |
| pub branch: Option<String>, | |
| } | |
| fn parse_attempts(input: &str) -> Result<usize, String> { | |
| let value: usize = input | |
| .parse() | |
| .map_err(|_| "attempts must be an integer between 1 and 4".to_string())?; | |
| if (1..=4).contains(&value) { | |
| Ok(value) | |
| } else { | |
| Err("attempts must be between 1 and 4".to_string()) | |
| } | |
| } | |
| fn parse_limit(input: &str) -> Result<i64, String> { | |
| let value: i64 = input | |
| .parse() | |
| .map_err(|_| "limit must be an integer between 1 and 20".to_string())?; | |
| if (1..=20).contains(&value) { | |
| Ok(value) | |
| } else { | |
| Err("limit must be between 1 and 20".to_string()) | |
| } | |
| } | |
| pub struct StatusCommand { | |
| /// Codex Cloud task identifier to inspect. | |
| pub task_id: String, | |
| } | |
| pub struct ListCommand { | |
| /// Filter tasks by environment identifier. | |
| pub environment: Option<String>, | |
| /// Maximum number of tasks to return (1-20). | |
| pub limit: i64, | |
| /// Pagination cursor returned by a previous call. | |
| pub cursor: Option<String>, | |
| /// Emit JSON instead of plain text. | |
| pub json: bool, | |
| } | |
| pub struct ApplyCommand { | |
| /// Codex Cloud task identifier to apply. | |
| pub task_id: String, | |
| /// Attempt number to apply (1-based). | |
| pub attempt: Option<usize>, | |
| } | |
| pub struct DiffCommand { | |
| /// Codex Cloud task identifier to display. | |
| pub task_id: String, | |
| /// Attempt number to display (1-based). | |
| pub attempt: Option<usize>, | |
| } | |