Skip to content
Merged
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
13 changes: 9 additions & 4 deletions src/lib/nodes/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,19 @@ const create = new Command("create")
.showHelpAfterError()
.argument(
"[names...]",
"Names of the nodes to create (must be unique across your account)",
"[Required: names or --count] Names of the nodes to create (must be unique across your account)",
)
.option(
"-n, --count <number>",
"Number of nodes to create with auto-generated names",
"[Required: names or --count] Number of nodes to create with auto-generated names",
validateCount,
)
.addOption(zoneOption)
.addOption(maxPriceOption)
.addOption(
new Option(
"--reserved",
"Create reserved nodes. Reserved nodes have an explicit start and end time.",
"Create reserved nodes (default). Reserved nodes have an explicit start and end time.",
).conflicts("auto"),
)
.addOption(
Expand Down Expand Up @@ -192,6 +192,11 @@ const create = new Command("create")
.addHelpText(
"after",
`
Notes:
- Either provide node names as arguments OR use --count (one is required)
- For reserved nodes (default): either --duration or --end is required
- For auto-reserved nodes (--auto): --duration and --end are not allowed

Examples:\n
\x1b[2m# Create a single reserved node(default type) that starts immediately\x1b[0m
$ sf nodes create -n 1 --zone hayesvalley --max-price 12.50 --duration 1h
Expand All @@ -206,7 +211,7 @@ Examples:\n
$ sf nodes create node-1 --zone hayesvalley --reserved --start "2024-01-15T10:00:00Z" --end "2024-01-15T12:00:00Z" -p 15.00

\x1b[2m# Create a reserved node with custom user-data for 2 hours starting now \x1b[0m
$ sf nodes create node-1 --zone hayesvalley --reserved --user-data-file /path/to/cloud-init --duration 2h -p 13.50
$ sf nodes create node-1 --zone hayesvalley --reserved --user-data-file /path/to/cloud-init --duration 2h -p 13.50

\x1b[2m# Create a reserved node starting in 1 hour for 6 hours\x1b[0m
$ sf nodes create node-1 --zone hayesvalley --reserved --start "+1h" --duration 6h -p 11.25
Expand Down
2 changes: 1 addition & 1 deletion src/lib/nodes/extend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Examples:\n
$ sf nodes extend my-node --duration 1h --max-price 15.00

\x1b[2m# Extend multiple nodes by node ID instead of name\x1b[0m
$ sf nodes extend node-abc123 node-abc124 node-abc125 --duration 2h --max-price 10.00
$ sf nodes extend n_b1dc52505c6db142 n_c1ed52505c6db142 --duration 2h --max-price 10.00

\x1b[2m# Extend with raw seconds\x1b[0m
$ sf nodes extend my-node --duration 7200 --max-price 10.00
Expand Down
10 changes: 5 additions & 5 deletions src/lib/nodes/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,31 +261,31 @@ export const yesOption = new Option(
*/
export const zoneOption = new Option(
"-z, --zone <zone>",
"Zone to create the nodes in",
"[Required] Zone for your nodes",
).makeOptionMandatory();

/**
* Common --max-price option for nodes commands
*/
export const maxPriceOption = new Option(
"-p, --max-price <price>",
"Maximum price per node hour in dollars",
"[Required] Maximum price per node hour in dollars",
).argParser(validatePrice).makeOptionMandatory();

/**
* Common --start option using same parser as buy command
*/
export const startOrNowOption = new Option(
"-s, --start <start>",
"Start time (ISO 8601 format or relative time like '+1d', or 'NOW')",
"Start time (ISO 8601 format:'2022-10-27T14:30:00Z' or relative time like '+1d', or 'NOW')",
).argParser(parseStartDateOrNow).default("NOW" as const);

/**
* Common --end option using same parser as buy command
*/
export const endOption = new Option(
"-e, --end <end>",
"End time (ISO 8601 format or relative time like '+1d', rounded up to nearest hour)",
"End time (ISO 8601 format:'2022-10-27T14:30:00Z' or relative time like '+1d', rounded up to nearest hour)",
).argParser(parseEnd);

/**
Expand All @@ -301,5 +301,5 @@ export const durationOption = new Option(
*/
export const requiredDurationOption = new Option(
"-d, --duration <duration>",
"Duration (e.g., '1h', '30m', '2d', 3600) - rounded up to the nearest hour",
"[Required] Duration (e.g., '1h', '30m', '2d', 3600) - rounded up to the nearest hour",
).argParser(parseDurationArgument).makeOptionMandatory();