Skip to content

Commit eaa5fda

Browse files
chore: consistancy for args and flags
1 parent 86a92f9 commit eaa5fda

54 files changed

Lines changed: 638 additions & 616 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 109 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ createos --help
7878

7979
### Projects
8080

81-
| Command | Description |
82-
| -------------------------- | ---------------- |
83-
| `createos projects list` | List all projects |
81+
| Command | Description |
82+
| -------------------------- | ------------------- |
83+
| `createos projects list` | List all projects |
8484
| `createos projects get` | Get project details |
85-
| `createos projects delete` | Delete a project |
85+
| `createos projects delete` | Delete a project |
8686

8787
### Deployments
8888

@@ -93,7 +93,7 @@ createos --help
9393
| `createos deployments build-logs` | Stream build logs for a deployment |
9494
| `createos deployments retrigger` | Retrigger a deployment |
9595
| `createos deployments wakeup` | Wake up a sleeping deployment |
96-
| `createos deployments cancel` | Cancel a deployment |
96+
| `createos deployments cancel` | Cancel a running deployment |
9797

9898
### Environments
9999

@@ -104,30 +104,43 @@ createos --help
104104

105105
### Environment Variables
106106

107-
| Command | Description |
108-
| ---------------------- | ------------------------------------------------- |
109-
| `createos env list` | List environment variables for a project |
110-
| `createos env set` | Set one or more environment variables |
111-
| `createos env rm` | Remove an environment variable |
112-
| `createos env pull` | Download environment variables to a local `.env` file |
113-
| `createos env push` | Upload environment variables from a local `.env` file |
107+
| Command | Description |
108+
| ------------------- | ----------------------------------------------------- |
109+
| `createos env list` | List environment variables for a project |
110+
| `createos env set` | Set one or more environment variables |
111+
| `createos env rm` | Remove an environment variable |
112+
| `createos env pull` | Download environment variables to a local `.env` file |
113+
| `createos env push` | Upload environment variables from a local `.env` file |
114114

115115
### Domains
116116

117-
| Command | Description |
118-
| -------------------------- | --------------------------------- |
119-
| `createos domains list` | List custom domains for a project |
120-
| `createos domains add` | Add a custom domain |
121-
| `createos domains verify` | Check DNS propagation and wait for verification |
122-
| `createos domains delete` | Remove a custom domain |
117+
| Command | Description |
118+
| ------------------------- | ----------------------------------------------- |
119+
| `createos domains list` | List custom domains for a project |
120+
| `createos domains create` | Create a custom domain for a project |
121+
| `createos domains verify` | Check DNS propagation and wait for verification |
122+
| `createos domains delete` | Delete a custom domain |
123+
124+
### Cron Jobs
125+
126+
| Command | Description |
127+
| -------------------------------- | -------------------------------------- |
128+
| `createos cronjobs list` | List cron jobs for a project |
129+
| `createos cronjobs create` | Create a new HTTP cron job |
130+
| `createos cronjobs get` | Show details for a cron job |
131+
| `createos cronjobs update` | Update a cron job's settings |
132+
| `createos cronjobs suspend` | Pause a cron job |
133+
| `createos cronjobs unsuspend` | Resume a suspended cron job |
134+
| `createos cronjobs activities` | Show recent execution history |
135+
| `createos cronjobs delete` | Delete a cron job |
123136

124137
### Templates
125138

126-
| Command | Description |
127-
| -------------------------- | --------------------------------------------- |
128-
| `createos templates list` | Browse available project templates |
129-
| `createos templates info` | Show details about a template |
130-
| `createos templates use` | Download and scaffold a project from a template |
139+
| Command | Description |
140+
| ------------------------- | ------------------------------------------------ |
141+
| `createos templates list` | Browse available project templates |
142+
| `createos templates info` | Show details about a template |
143+
| `createos templates use` | Download and scaffold a project from a template |
131144

132145
### VMs
133146

@@ -150,20 +163,21 @@ createos --help
150163

151164
### Quick Actions
152165

153-
| Command | Description |
154-
| ----------------- | ------------------------------------------------- |
155-
| `createos init` | Link the current directory to a CreateOS project |
156-
| `createos status` | Show a project's health and deployment status |
157-
| `createos open` | Open a project's live URL in your browser |
158-
| `createos scale` | Adjust replicas and resources for an environment |
166+
| Command | Description |
167+
| ----------------- | ------------------------------------------------ |
168+
| `createos init` | Link the current directory to a CreateOS project |
169+
| `createos status` | Show a project's health and deployment status |
170+
| `createos open` | Open a project's live URL in your browser |
171+
| `createos scale` | Adjust replicas and resources for an environment |
159172

160173
### OAuth Clients
161174

162-
| Command | Description |
163-
| -------------------------------------- | ------------------------------------- |
164-
| `createos oauth-clients list` | List your OAuth clients |
165-
| `createos oauth-clients create` | Create a new OAuth client |
166-
| `createos oauth-clients instructions` | Show setup instructions for a client |
175+
| Command | Description |
176+
| ------------------------------------- | ------------------------------------ |
177+
| `createos oauth-clients list` | List your OAuth clients |
178+
| `createos oauth-clients create` | Create a new OAuth client |
179+
| `createos oauth-clients instructions` | Show setup instructions for a client |
180+
| `createos oauth-clients delete` | Delete an OAuth client |
167181

168182
### Me
169183

@@ -182,57 +196,98 @@ createos --help
182196

183197
## Non-interactive / CI usage
184198

185-
All commands that would normally show an interactive prompt accept flags instead:
199+
All commands accept flags so they work in CI and non-interactive environments. Destructive commands require `--force` to skip the confirmation prompt.
186200

187201
```bash
188-
# OAuth clients
189-
createos oauth-clients instructions --client <client-id>
190-
createos oauth-clients create \
191-
--name "My App" \
192-
--redirect-uri https://myapp.com/callback \
193-
--app-url https://myapp.com \
194-
--policy-url https://myapp.com/privacy \
195-
--tos-url https://myapp.com/tos \
196-
--logo-url https://myapp.com/logo.png
197-
198202
# Projects
199203
createos projects get --project <id>
204+
createos projects delete --project <id> --force
200205

201206
# Deployments
207+
createos deployments list --project <id>
202208
createos deployments logs --project <id> --deployment <id>
209+
createos deployments build-logs --project <id> --deployment <id>
203210
createos deployments retrigger --project <id> --deployment <id>
211+
createos deployments wakeup --project <id> --deployment <id>
212+
createos deployments cancel --project <id> --deployment <id> --force
204213

205214
# Environments
206-
createos environments delete --project <id> --environment <id>
215+
createos environments list --project <id>
216+
createos environments delete --project <id> --environment <id> --force
207217

208218
# Environment variables
209219
createos env list --project <id> --environment <id>
210220
createos env set KEY=value --project <id> --environment <id>
221+
createos env rm KEY --project <id> --environment <id>
211222
createos env pull --project <id> --environment <id> --force
223+
createos env push --project <id> --environment <id> --force
212224

213225
# Domains
214-
createos domains add example.com --project <id>
226+
createos domains list --project <id>
227+
createos domains create --project <id> --name example.com
215228
createos domains verify --project <id> --domain <id> --no-wait
216-
createos domains delete --project <id> --domain <id>
229+
createos domains delete --project <id> --domain <id> --force
230+
231+
# Cron jobs
232+
createos cronjobs list --project <id>
233+
createos cronjobs create --project <id> --environment <id> \
234+
--name "Cleanup job" --schedule "0 * * * *" \
235+
--path /api/cleanup --method POST
236+
createos cronjobs delete --project <id> --cronjob <id> --force
217237

218238
# Templates
219239
createos templates use --template <id> --yes
220240

221241
# VMs
242+
createos vms list
222243
createos vms get --vm <id>
244+
createos vms deploy --zone nyc3 --size 1 --name "my-vm" --ssh-key "ssh-ed25519 ..."
223245
createos vms reboot --vm <id> --force
224246
createos vms terminate --vm <id> --force
225247
createos vms resize --vm <id> --size 1
226-
createos vms deploy --zone nyc3 --size 1
248+
249+
# OAuth clients
250+
createos oauth-clients list
251+
createos oauth-clients create \
252+
--name "My App" \
253+
--redirect-uri https://myapp.com/callback \
254+
--app-url https://myapp.com \
255+
--policy-url https://myapp.com/privacy \
256+
--tos-url https://myapp.com/tos \
257+
--logo-url https://myapp.com/logo.png
258+
createos oauth-clients instructions --client <id>
259+
createos oauth-clients delete --client <id> --force
260+
261+
# Me
262+
createos me oauth-consents list
263+
createos me oauth-consents revoke --client <id> --force
264+
```
265+
266+
## JSON output and piping
267+
268+
All list and get commands output JSON automatically when stdout is a pipe, so `| jq` works without any flags:
269+
270+
```bash
271+
createos projects list | jq '.[].id'
272+
createos deployments list --project <id> | jq '.[] | select(.status == "running")'
273+
createos cronjobs list --project <id> | jq '.[] | {id, name, schedule}'
274+
createos vms list | jq '.[].extra.ip_address'
275+
```
276+
277+
To force JSON output in a TTY, use `--output json` (or `-o json`):
278+
279+
```bash
280+
createos projects get --project <id> --output json
281+
createos environments list --project <id> -o json
227282
```
228283

229284
## Options
230285

231-
| Flag | Description |
232-
| ------------- | ----------------------------------------------------- |
233-
| `--output json` | Output results as JSON (supported on most list/get commands) |
234-
| `--debug, -d` | Print HTTP request/response details (token is masked) |
235-
| `--api-url` | Override the API base URL |
286+
| Flag | Description |
287+
| --------------------- | -------------------------------------------------------------------- |
288+
| `--output, -o <fmt>` | Output format: `json` or `table` (default). Auto-json when piped. |
289+
| `--debug, -d` | Print HTTP request/response details (token is masked) |
290+
| `--api-url` | Override the API base URL |
236291

237292
## Security
238293

cmd/cronjobs/cronjobs_activities.go

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import (
77
"github.com/urfave/cli/v2"
88

99
"github.com/NodeOps-app/createos-cli/internal/api"
10+
"github.com/NodeOps-app/createos-cli/internal/output"
1011
)
1112

1213
func newCronjobsActivitiesCommand() *cli.Command {
1314
return &cli.Command{
14-
Name: "activities",
15-
Usage: "Show recent execution history for a cron job",
16-
ArgsUsage: "[project-id] [cronjob-id]",
15+
Name: "activities",
16+
Usage: "Show recent execution history for a cron job",
1717
Flags: []cli.Flag{
1818
&cli.StringFlag{Name: "project", Usage: "Project ID"},
1919
&cli.StringFlag{Name: "cronjob", Usage: "Cron job ID"},
@@ -34,47 +34,46 @@ func newCronjobsActivitiesCommand() *cli.Command {
3434
return err
3535
}
3636

37-
if len(activities) == 0 {
38-
fmt.Println("No execution history found for this cron job yet.")
39-
return nil
40-
}
41-
42-
tableData := pterm.TableData{
43-
{"ID", "Success", "Status Code", "Scheduled At", "Log"},
44-
}
45-
for _, a := range activities {
46-
success := "-"
47-
if a.Success != nil {
48-
if *a.Success {
49-
success = "yes"
50-
} else {
51-
success = "no"
52-
}
37+
output.Render(c, activities, func() {
38+
if len(activities) == 0 {
39+
fmt.Println("No execution history found for this cron job yet.")
40+
return
5341
}
54-
statusCode := "-"
55-
if a.StatusCode != nil {
56-
statusCode = fmt.Sprintf("%d", *a.StatusCode)
42+
43+
tableData := pterm.TableData{
44+
{"ID", "Success", "Status Code", "Scheduled At", "Log"},
5745
}
58-
log := "-"
59-
if a.Log != nil && *a.Log != "" {
60-
log = *a.Log
61-
if len(log) > 80 {
62-
log = log[:77] + "..."
46+
for _, a := range activities {
47+
success := "-"
48+
if a.Success != nil {
49+
if *a.Success {
50+
success = "yes"
51+
} else {
52+
success = "no"
53+
}
54+
}
55+
statusCode := "-"
56+
if a.StatusCode != nil {
57+
statusCode = fmt.Sprintf("%d", *a.StatusCode)
6358
}
59+
log := "-"
60+
if a.Log != nil && *a.Log != "" {
61+
log = *a.Log
62+
if len(log) > 80 {
63+
log = log[:77] + "..."
64+
}
65+
}
66+
tableData = append(tableData, []string{
67+
a.ID,
68+
success,
69+
statusCode,
70+
a.ScheduledAt.Format("2006-01-02 15:04:05"),
71+
log,
72+
})
6473
}
65-
tableData = append(tableData, []string{
66-
a.ID,
67-
success,
68-
statusCode,
69-
a.ScheduledAt.Format("2006-01-02 15:04:05"),
70-
log,
71-
})
72-
}
73-
74-
if err := pterm.DefaultTable.WithHasHeader().WithData(tableData).Render(); err != nil {
75-
return err
76-
}
77-
fmt.Println()
74+
_ = pterm.DefaultTable.WithHasHeader().WithData(tableData).Render()
75+
fmt.Println()
76+
})
7877
return nil
7978
},
8079
}

cmd/cronjobs/cronjobs_create.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ import (
1414

1515
func newCronjobsCreateCommand() *cli.Command {
1616
return &cli.Command{
17-
Name: "create",
18-
Usage: "Create a new HTTP cron job for a project",
19-
ArgsUsage: "[project-id]",
17+
Name: "create",
18+
Usage: "Create a new HTTP cron job for a project",
2019
Description: `Create a new HTTP cron job that fires on a cron schedule.
2120
2221
Examples:
@@ -37,11 +36,7 @@ Examples:
3736
return fmt.Errorf("you're not signed in — run 'createos login' to get started")
3837
}
3938

40-
pid := c.String("project")
41-
if pid == "" {
42-
pid = c.Args().First()
43-
}
44-
projectID, err := cmdutil.ResolveProjectID(pid)
39+
projectID, err := cmdutil.ResolveProjectID(c.String("project"))
4540
if err != nil {
4641
return err
4742
}

cmd/cronjobs/cronjobs_delete.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ func newCronjobsDeleteCommand() *cli.Command {
1414
return &cli.Command{
1515
Name: "delete",
1616
Usage: "Delete a cron job",
17-
ArgsUsage: "[project-id] [cronjob-id]",
1817
Description: `Permanently delete a cron job. This action cannot be undone.
1918
2019
Examples:

0 commit comments

Comments
 (0)