1Feature: Non-interactive execution
2
3 keld is often invoked from systemd timers, cron jobs, CI pipelines,
4 and shell scripts where no controlling terminal is attached. In those
5 contexts it must run restic directly without attempting to launch the
6 interactive TUI. When a user wants scripted behaviour even on a
7 terminal, an environment variable provides an escape hatch.
8
9 Rule: Without a terminal keld never launches the interactive TUI
10
11 Scenario: Wrapped subcommand runs restic when the preset supplies everything
12 Given keld is invoked with a wrapped subcommand and no positional arguments
13 And standard input is not a terminal
14 And the selected preset supplies every value the command needs
15 When keld runs
16 Then restic is executed with the resolved configuration
17 And no interactive TUI is launched
18
19 Scenario: Wrapped subcommand runs restic when positional arguments cover missing values
20 Given keld is invoked with a wrapped subcommand and positional arguments
21 And standard input is not a terminal
22 When keld runs
23 Then restic is executed with the resolved configuration
24 And no interactive TUI is launched
25
26 Scenario: --show-command prints the resolved command without launching the TUI
27 Given keld is invoked non-interactively with --show-command
28 When keld runs
29 Then the resolved restic command is printed
30 And keld exits successfully without executing restic
31 And no interactive TUI is launched
32
33 Rule: Non-interactive mode requires explicit inputs
34
35 Scenario: Multiple presets are configured and none is specified
36 Given the configuration defines more than one preset
37 And keld is invoked non-interactively without --preset
38 When keld runs
39 Then keld fails with an error naming the --preset flag
40 And the error lists the available presets
41 And no interactive TUI is launched
42
43 Scenario: Backup invoked with no paths available
44 Given keld is invoked non-interactively with the backup subcommand
45 And no paths are provided on the command line
46 And the resolved preset defines no backup paths
47 When keld runs
48 Then keld fails with an error naming the missing paths
49 And no interactive TUI is launched
50
51 Scenario: Bare keld with no subcommand
52 Given keld is invoked non-interactively with no subcommand
53 When keld runs
54 Then keld fails with an error naming the missing subcommand
55 And no interactive TUI is launched
56
57 Rule: Interactive mode is preserved when a terminal is attached
58
59 Scenario: Wrapped subcommand with no arguments opens the session
60 Given keld is invoked with a wrapped subcommand and no positional arguments
61 And standard input is a terminal
62 When keld runs
63 Then the interactive session is launched with the command pre-selected
64
65 Scenario: Bare keld opens the command menu
66 Given keld is invoked with no subcommand
67 And standard input is a terminal
68 When keld runs
69 Then the interactive session is launched starting at the command menu
70
71 Rule: KELD_NONINTERACTIVE overrides terminal detection
72
73 Scenario: Environment variable forces non-interactive behaviour on a terminal
74 Given keld is invoked with a wrapped subcommand and no positional arguments
75 And standard input is a terminal
76 And KELD_NONINTERACTIVE is set to a non-empty value
77 When keld runs
78 Then restic is executed with the resolved configuration
79 And no interactive TUI is launched
80
81 Scenario: Empty KELD_NONINTERACTIVE is treated as unset
82 Given keld is invoked with a wrapped subcommand and no positional arguments
83 And standard input is a terminal
84 And KELD_NONINTERACTIVE is set to an empty value
85 When keld runs
86 Then the interactive session is launched with the command pre-selected