added directly mode on some commands (#31)

This commit is contained in:
Arwid Thornström
2025-11-06 13:30:10 +01:00
committed by GitHub
parent 1ed0f300dc
commit 7e50d5eb54
4 changed files with 415 additions and 52 deletions
+143 -2
View File
@@ -2,6 +2,54 @@
**pwcli** is a CLI for Photowall platform that provides commands for deployment, AWS operations, workflow automation, and more.
## Quick Command Reference
```
pwcli
├── ai (ai)
│ └── promptcontextlibrary (pcl) ..................... ai pcl
├── aws (a)
│ ├── ecs (e)
│ │ └── sshtestserver (sts) ....................... a e sts
│ ├── logs (l) ....................................... a l
│ ├── parameterstore (ps)
│ │ ├── bulk-create (bc) .......................... a ps bc
│ │ ├── create (c) ................................ a ps c
│ │ ├── list (l) .................................. a ps l
│ │ └── update (u) ................................ a ps u
│ ├── pipeline (pl)
│ │ └── status (s) ................................ a pl s
│ └── s3 (s3)
│ ├── clear_prints (cp) ......................... a s3 cp
│ ├── print_on_station (pos) .................... a s3 pos
│ └── sync_images (si) .......................... a s3 si
├── deployment (d)
│ └── testservers (ts)
│ ├── create (c) ................................ d ts c
│ ├── delete (d) ................................ d ts d
│ ├── status (s) ................................ d ts s
│ └── update (u) ................................ d ts u
├── mandrill (m)
│ └── fix_template (ft) .............................. m ft
├── setup (s)
│ └── settings (se) .................................. s se
├── test (t)
│ └── routes (r) ..................................... t r
├── update (up) ........................................ up
└── workflow (wf)
├── git (g)
│ ├── clean_local_branches (clb) ................ wf g clb
│ └── clean_old_branches (cb) ................... wf g cb
└── setupissue (si) ................................ wf si
```
## Usage
Run `pwcli` to start the interactive menu, or use command shortcuts directly:
@@ -81,12 +129,23 @@ Deployment and test server management
- **create** (alias: `c`) - Create new testserver on AWS
- **delete** (alias: `d`) - Choose a testserver to delete
- **status** (alias: `s`) - Show status for available testservers
- Flags:
- `--json` - Output status information in JSON format (non-interactive)
- **update** (alias: `u`) - Update stack with different branch
- Flags:
- `--branch <branch>` - Specify GitHub branch to deploy
- `--stack <stack>` - Specify test stack (formats: `photowall-test-01`, `test-01`, or `01`)
- `--skip-confirm` - Skip confirmation prompt when using parameters
- `--json` - Output result in JSON format with success flag and message
**Examples:**
- `pwcli d ts s` - View testserver status
- `pwcli d ts s` - View testserver status (interactive)
- `pwcli d ts s --json` - View testserver status as JSON
- `pwcli d ts c` - Create new testserver
- `pwcli d ts u` - Update existing testserver
- `pwcli d ts u` - Update existing testserver (interactive)
- `pwcli d ts u --branch feature/123 --stack test-01` - Update test-01 with feature/123 branch (with confirmation)
- `pwcli d ts u --branch feature/123 --stack test-01 --skip-confirm` - Update without confirmation
- `pwcli d ts u --branch feature/123 --stack 01 --skip-confirm --json` - Update and output JSON result
---
@@ -168,5 +227,87 @@ Settings are stored in `~/.pwcli_settings`
---
## Non-Interactive Mode & JSON Output
Several commands support non-interactive mode with JSON output, making them perfect for CI/CD pipelines and automation scripts.
### Testserver Status with JSON Output
Get testserver status information in JSON format:
```bash
pwcli d ts s --json
```
**JSON Output Format:**
```json
[
{
"name": "photowall-test-01",
"status": "UPDATE_COMPLETE",
"branch": "feature/123-my-feature",
"issueNumber": "123",
"issueStatus": "✅ open",
"issueUpdated": "2025-11-06T10:30:00Z",
"created": "2025-10-15T08:00:00Z",
"updated": "2025-11-05T14:20:00Z",
"url": "https://test-01.photowall-test.com/us"
}
]
```
### Testserver Update - Non-Interactive
Update a testserver without interactive prompts:
```bash
pwcli d ts u --branch feature/123 --stack test-01 --skip-confirm --json
```
**Success Response:**
```json
{
"success": true,
"message": "Successfully updated photowall-test-01 with branch feature/123 and started pipeline",
"stack": "photowall-test-01",
"branch": "feature/123",
"pipeline": "photowall-test-01Pipeline"
}
```
**Error Response:**
```json
{
"success": false,
"message": "Not a valid branch on photowall repo: invalid-branch"
}
```
### Automation Examples
**In a CI/CD Pipeline:**
```bash
#!/bin/bash
# Deploy to testserver and check result
result=$(pwcli d ts u --branch $CI_BRANCH --stack test-01 --skip-confirm --json)
success=$(echo $result | jq -r '.success')
if [ "$success" == "true" ]; then
echo "Deployment successful!"
exit 0
else
echo "Deployment failed!"
exit 1
fi
```
**Check testserver availability:**
```bash
# Get all testservers and find an available one
pwcli d ts s --json | jq '.[] | select(.status == "UPDATE_COMPLETE") | .name'
```
---
For more information, visit the repository or run commands interactively with `pwcli`