8000 Add memory limit option to CLI by paulgb · Pull Request #131 · jamsocket/forevervm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add memory limit option to CLI #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions rust/forevervm/src/commands/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ pub async fn machine_list(tags: std::collections::HashMap<String, String>) -> an
Ok(())
}

pub async fn machine_new(tags: std::collections::HashMap<String, String>) -> anyhow::Result<()> {
pub async fn machine_new(
tags: std::collections::HashMap<String, String>,
memory_mb: Option<u32>,
) -> anyhow::Result<()> {
let client = ConfigManager::new()?.client()?;

let request = CreateMachineRequest {
tags,
memory_mb: None,
};
let request = CreateMachineRequest { tags, memory_mb };
let machine = client.create_machine(request).await?;

println!(
Expand Down
8 changes: 6 additions & 2 deletions rust/forevervm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ enum MachineCommands {
/// Add tags to the machine in the format key=value
#[arg(long = "tag", value_parser = parse_key_val, action = clap::ArgAction::Append)]
tags: Option<Vec<(String, String)>>,

/// Memory size in MB (if not specified, a default value will be used)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth saying what the default is? Or is that risky in case it changes later?

#[arg(long)]
memory_mb: Option<u32>,
},
/// List all machines
List {
Expand Down Expand Up @@ -95,11 +99,11 @@ async fn main_inner() -> anyhow::Result<()> {
whoami().await?;
}
Commands::Machine { command } => match command {
MachineCommands::New { tags } => {
MachineCommands::New { tags, memory_mb } => {
let tags_map = tags
.map(|tags| tags.into_iter().collect::<HashMap<String, String>>())
.unwrap_or_default();
machine_new(tags_map).await?;
machine_new(tags_map, memory_mb).await?;
}
MachineCommands::List { tags } => {
let tags_map = tags
Expand Down
0