aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2025-06-19 09:08:38 +0100
committerdiogo464 <[email protected]>2025-06-19 09:08:38 +0100
commit413b3214f2a1a5714fe872220c46ff210178ab76 (patch)
treeac2716840b33a79be26318f6e3f177b4b61e93c7 /tests
parentb7ff8b4b76236d7ceb1abe87d5c1c4ab2cad61bf (diff)
Add quiet flag to list command for machine-readable output
- Add ListArgs struct with quiet boolean flag - Convert List command from unit variant to struct variant - In quiet mode: no headers, colon-separated format (id:pid:status) - In normal mode: preserve existing table format - Handle quiet mode in all output scenarios (normal, error cases) - Add comprehensive test for quiet mode functionality Example usage: demon list # Normal table output demon list -q # Quiet: process1:123:RUNNING 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/cli.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
index 7cb68b7..05e3efd 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -343,4 +343,37 @@ fn test_invalid_process_id() {
343 .assert() 343 .assert()
344 .success() 344 .success()
345 .stdout(predicate::str::contains("invalid PID file")); 345 .stdout(predicate::str::contains("invalid PID file"));
346}
347
348#[test]
349fn test_list_quiet_mode() {
350 let temp_dir = TempDir::new().unwrap();
351
352 // Test quiet mode with no processes
353 let mut cmd = Command::cargo_bin("demon").unwrap();
354 cmd.current_dir(temp_dir.path())
355 .args(&["list", "--quiet"])
356 .assert()
357 .success()
358 .stdout(predicate::str::is_empty());
359
360 // Create a process
361 let mut cmd = Command::cargo_bin("demon").unwrap();
362 cmd.current_dir(temp_dir.path())
363 .args(&["run", "--id", "quiet-test", "echo", "done"])
364 .assert()
365 .success();
366
367 // Test quiet mode with process - should output colon-separated format
368 let mut cmd = Command::cargo_bin("demon").unwrap();
369 cmd.current_dir(temp_dir.path())
370 .args(&["list", "-q"])
371 .assert()
372 .success()
373 .stdout(predicate::str::contains("quiet-test:"))
374 .stdout(predicate::str::contains(":DEAD"))
375 // Should not contain headers
376 .stdout(predicate::str::contains("ID").not())
377 .stdout(predicate::str::contains("PID").not())
378 .stdout(predicate::str::contains("STATUS").not());
346} \ No newline at end of file 379} \ No newline at end of file