daedalus-tools 0.13.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. daedalus_tools-0.13.0/MANIFEST.in +5 -0
  2. daedalus_tools-0.13.0/PKG-INFO +251 -0
  3. daedalus_tools-0.13.0/README.md +243 -0
  4. daedalus_tools-0.13.0/bash/daedalus_common.sh +35 -0
  5. daedalus_tools-0.13.0/bash/hello_bash.sh +27 -0
  6. daedalus_tools-0.13.0/batch/.gitkeep +0 -0
  7. daedalus_tools-0.13.0/batch/README.md +6 -0
  8. daedalus_tools-0.13.0/daedalus/__init__.py +52 -0
  9. daedalus_tools-0.13.0/daedalus/__main__.py +9 -0
  10. daedalus_tools-0.13.0/daedalus/cli.py +229 -0
  11. daedalus_tools-0.13.0/daedalus/completions.py +140 -0
  12. daedalus_tools-0.13.0/daedalus/daedalus_logging/__init__.py +91 -0
  13. daedalus_tools-0.13.0/daedalus/registry.py +103 -0
  14. daedalus_tools-0.13.0/daedalus/run_python_script.py +62 -0
  15. daedalus_tools-0.13.0/daedalus/runners.py +121 -0
  16. daedalus_tools-0.13.0/daedalus_tools.egg-info/PKG-INFO +251 -0
  17. daedalus_tools-0.13.0/daedalus_tools.egg-info/SOURCES.txt +31 -0
  18. daedalus_tools-0.13.0/daedalus_tools.egg-info/dependency_links.txt +1 -0
  19. daedalus_tools-0.13.0/daedalus_tools.egg-info/entry_points.txt +2 -0
  20. daedalus_tools-0.13.0/daedalus_tools.egg-info/requires.txt +1 -0
  21. daedalus_tools-0.13.0/daedalus_tools.egg-info/top_level.txt +1 -0
  22. daedalus_tools-0.13.0/powershell/.gitkeep +0 -0
  23. daedalus_tools-0.13.0/powershell/README.md +6 -0
  24. daedalus_tools-0.13.0/pyproject.toml +56 -0
  25. daedalus_tools-0.13.0/python/src/gpgtools/gpgtools.py +1249 -0
  26. daedalus_tools-0.13.0/python/src/gpgtools/spec.md +375 -0
  27. daedalus_tools-0.13.0/python/src/hello/hello.py +51 -0
  28. daedalus_tools-0.13.0/python/src/hello/spec.md +33 -0
  29. daedalus_tools-0.13.0/python/src/init/init.py +122 -0
  30. daedalus_tools-0.13.0/python/src/init/spec.md +92 -0
  31. daedalus_tools-0.13.0/python/src/publish/publish.py +208 -0
  32. daedalus_tools-0.13.0/python/src/publish/spec.md +119 -0
  33. daedalus_tools-0.13.0/setup.cfg +4 -0
@@ -0,0 +1,5 @@
1
+ # Ship the declared script folders even while they hold only
2
+ # README placeholders, so every sdist can rebuild its wheel
3
+ # (SPEC item 9.2.1). File types are filtered per 9.2 on install.
4
+ recursive-include powershell *
5
+ recursive-include batch *
@@ -0,0 +1,251 @@
1
+ Metadata-Version: 2.4
2
+ Name: daedalus-tools
3
+ Version: 0.13.0
4
+ Summary: Template for daedalus: loose scripts in one repo, run with: daedalus <name> [args...]
5
+ Requires-Python: >=3.11
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: argcomplete>=3.3
8
+
9
+ # daedalus (template)
10
+
11
+ Starter repository for daedalus:
12
+ one CLI, many small scripts, each with tests.
13
+
14
+ ```bash
15
+ daedalus <name> [args...] # run a script
16
+ daedalus <category> [category...] # list scripts in the categories (AND)
17
+ daedalus --list # list everything
18
+ ```
19
+
20
+ **[Install, usage, and development](./INSTALL.md)** ·
21
+ [SPEC](./SPEC.md) (how the repo is maintained) ·
22
+ [CHANGELOG](./CHANGELOG.md)
23
+
24
+ ## Available scripts
25
+
26
+ | Script | Type | Categories | What it does |
27
+ | --- | --- | --- | --- |
28
+ | `gpgtools` | Python | gpg | YubiKey GPG/SSH helpers: initialize (gnupg readiness check + install), initialize_yubikey (fresh machine, steps 1-4), send_pubkey (resolve key, verify possession, append to a server), store_publickey (install the key from the machine being granted access), configure_ssh (marker-managed per-host ssh block) |
29
+ | `hello` | Python | test | Prints a hello line and the daedalus version |
30
+ | `hello_bash` | Bash | test | Sample bash script through the shared help() interface |
31
+ | `init` | Python | setup | Enable tab completion for daedalus: register argcomplete in bash (appends the managed hook block to ~/.bashrc), idempotent |
32
+ | `publish` | Python | release | Release daedalus to PyPI: guarded chained build (clean tree, exact `v<version>` tag, PyPI-free version, tooling), twine check, `--upload` (credentials stay with twine) |
33
+
34
+ Run the sample script:
35
+
36
+ ```bash
37
+ daedalus hello # hello from daedalus 0.4.0
38
+ daedalus hello_bash me # hello, me (from daedalus bash)
39
+ daedalus hello_bash -h # usage from hello_bash's help()
40
+ daedalus test hello # same, through the category prefix
41
+ daedalus test # list the scripts in the 'test' category
42
+ ```
43
+
44
+ `daedalus --list` prints the version, a `script` / `type` / `categories`
45
+ table, and each description wrapped under each row.
46
+
47
+ ### gpgtools
48
+
49
+ `initialize` checks that gnupg is ready on this machine and installs
50
+ what is missing — the gnupg-only half of `initialize_yubikey`, with no
51
+ card expectations. Its use is on-site: on a bare server where you are
52
+ about to run `store_publickey --fingerprint`, this is the command that
53
+ makes the gpg-dependent sources work.
54
+
55
+ ```bash
56
+ daedalus gpgtools initialize # check gnupg, install when missing
57
+ daedalus gpgtools initialize --dry-run # already ready, or the install command
58
+ ```
59
+
60
+ | Argument | Default | Meaning |
61
+ | --- | --- | --- |
62
+ | `--dry-run` | off | Print what would happen (already ready or the install command); change nothing |
63
+
64
+ Exit codes: `0` gnupg ready (installed or already present), `2` package
65
+ install failed or gpg still unusable after it, `3` gpg missing and no
66
+ known package manager.
67
+
68
+ `initialize_yubikey` runs the fresh-machine flow for YubiKey-backed
69
+ GPG and SSH (steps 1-4 of the wiki guide): install gnupg when missing,
70
+ check the card, fetch the public key from the card's URL field, and
71
+ write the gpg-agent SSH config. Steps 5-7 are per-server and covered
72
+ by the subcommands below.
73
+
74
+ ```bash
75
+ daedalus gpgtools # overview of the subcommands
76
+ daedalus gpgtools initialize_yubikey # prepare this machine
77
+ daedalus gpgtools initialize_yubikey --dry-run # print the plan only
78
+ ```
79
+
80
+ | Argument | Default | Meaning |
81
+ | --- | --- | --- |
82
+ | `--dry-run` | off | Print the plan, write nothing |
83
+ | `--gnupg-home DIR` | `GNUPGHOME` or `~/.gnupg` | Which GnuPG home to configure |
84
+
85
+ Exit codes: `0` ready, `2` package install failed, `3` gpg missing and
86
+ no known package manager, `4` no card found, `5` public-key fetch did
87
+ not pair the keyring, `6` keyring unpaired and the card carries no URL.
88
+
89
+ `send_pubkey` covers guide steps 5-6 for one server: resolve the SSH
90
+ public key from one of five sources, prove possession of the private
91
+ half with a challenge signature (the YubiKey itself signs; PIN prompts
92
+ go to the user), then append the line to the target's
93
+ `authorized_keys` — idempotent, fingerprint-checked against stores,
94
+ and nothing is sent when verification fails.
95
+
96
+ ```bash
97
+ daedalus gpgtools send_pubkey --yubikey you@server
98
+ daedalus gpgtools send_pubkey --fingerprint <FP> you@server
99
+ daedalus gpgtools send_pubkey --url https://keys.openpgp.org/vks/v1/by-fingerprint/<FP> you@server
100
+ daedalus gpgtools send_pubkey --pubkey "ssh-ed25519 AAAA... comment" you@server
101
+ daedalus gpgtools send_pubkey --file /media/usb/yubikey_auth.pub you@server
102
+ daedalus gpgtools send_pubkey --yubikey --dry-run you@server # resolve only
103
+ ```
104
+
105
+ | Argument | Default | Meaning |
106
+ | --- | --- | --- |
107
+ | `--yubikey` | — | Key from the plugged YubiKey via gpg-agent (must be the only agent key) |
108
+ | `--url URL` | — | Armored OpenPGP public key at a URL ([A] subkey is exported) |
109
+ | `--fingerprint FP` | — | Searched: local keyring → keys.openpgp.org → keyserver.ubuntu.com |
110
+ | `--pubkey LINE` | — | The literal SSH public key line |
111
+ | `--file PATH` | — | File holding the key line, e.g. a `.pub` from a USB stick (no network, no gpg) |
112
+ | `--no-verify` | verification on | Skip the proof-of-possession signature (explicit risk acceptance) |
113
+ | `--dry-run` | off | Resolve and print the key; verify and send nothing |
114
+
115
+ Additional exit codes: `7` ssh to the target failed, `8` no source
116
+ resolved a key, `10` proof-of-possession verification failed (nothing
117
+ was sent).
118
+
119
+ `store_publickey` is the mirror for the on-site bootstrap: run it on
120
+ the machine that access is being granted *to* — a server with ssh
121
+ password authentication disabled that no key authorizes yet, where
122
+ you are logged in at the console. It resolves the same five sources
123
+ and appends the key into this machine's `authorized_keys`, so the
124
+ machine holding the YubiKey can ssh in afterwards. There is no
125
+ proof-of-possession (the private half is, by design, elsewhere);
126
+ instead both resolve-and-store subcommands print an identity block —
127
+ line, source, and the key material's SHA-256 — to compare across
128
+ machines. Existing entries are preserved, nothing is duplicated, and
129
+ directory/file modes are forced to 700/600.
130
+
131
+ ```bash
132
+ daedalus gpgtools store_publickey --file /media/usb/yubikey_auth.pub
133
+ daedalus gpgtools store_publickey --fingerprint <FP>
134
+ daedalus gpgtools store_publickey --pubkey "ssh-ed25519 AAAA... comment"
135
+ daedalus gpgtools store_publickey --file /media/usb/yubikey_auth.pub --dry-run # print only
136
+ ```
137
+
138
+ | Argument | Default | Meaning |
139
+ | --- | --- | --- |
140
+ | sources | — | Same five sources as `send_pubkey` (exactly one required) |
141
+ | `--authorized-keys FILE` | `~/.ssh/authorized_keys` | Where to install the key |
142
+ | `--dry-run` | off | Resolve and print the key; write nothing |
143
+
144
+ Additional exit codes: `8` no source resolved a key.
145
+
146
+ `configure_ssh` covers guide step 7 for one host: it writes a
147
+ marker-managed `Host <alias>` block into the ssh client config.
148
+ Outside the markers your config is preserved byte-for-byte; re-runs
149
+ replace the block (idempotent), and an unmanaged `Host` with the same
150
+ alias is refused rather than shadowed. It never connects anywhere.
151
+
152
+ ```bash
153
+ daedalus gpgtools configure_ssh --alias vault1 --hostname 203.0.113.10 --user admin
154
+ daedalus gpgtools configure_ssh --alias vault1 --dry-run # print only
155
+ daedalus gpgtools configure_ssh --alias vault1 --no-fallback # YubiKey only
156
+ ```
157
+
158
+ | Argument | Default | Meaning |
159
+ | --- | --- | --- |
160
+ | `--alias NAME` | required | The ssh Host alias to configure |
161
+ | `--hostname HOST` | the alias | HostName value |
162
+ | `--user USER` | ssh's default | User value |
163
+ | `--pubkey FILE` | `~/.ssh/yubikey_auth.pub` | Primary IdentityFile (must exist) |
164
+ | `--fallback FILE` | `~/.ssh/id_ed25519` | Fallback IdentityFile, included only when it exists |
165
+ | `--no-fallback` | off | Never add a fallback IdentityFile |
166
+ | `--config PATH` | `~/.ssh/config` | Which ssh client config to edit |
167
+
168
+ Additional exit code: `11` an unmanaged `Host` with the same alias exists in the
169
+ config (move it into the managed markers or rename the alias).
170
+
171
+ `ssh-config-summary` prints what is enabled where, read-only: one row per
172
+ managed block — alias, hostname, user, the key id (first 8 chars of the
173
+ identity's SHA256 fingerprint, material-digest fallback), and the fallback
174
+ identity. Same id on two rows means the same gpg key guards both hosts.
175
+
176
+ ```bash
177
+ daedalus gpgtools ssh-config-summary
178
+ daedalus gpgtools ssh-config-summary --config FILE
179
+ ```
180
+
181
+ | Argument | Default | Meaning |
182
+ | --- | --- | --- |
183
+ | `--config FILE` | `~/.ssh/config` | Which ssh client config to read |
184
+
185
+ ## Shell completion
186
+
187
+ Bash (and other shells argcomplete supports) completes script names and
188
+ category labels: `daedalus hel` + TAB completes `hello`, `daedalus test h` +
189
+ TAB completes `hello` inside the category, and options complete after `-`.
190
+ Run `daedalus init` once to register the hook in `~/.bashrc` (below); see
191
+ also [INSTALL](./INSTALL.md#tab-completion).
192
+
193
+ ### init
194
+
195
+ `init` is the one-time shell-side setup: it finds the
196
+ `register-python-argcomplete` that belongs to this exact daedalus
197
+ interpreter (so a pipx install wires its own venv, not some other
198
+ python), appends the hook to `~/.bashrc` between managed markers, and
199
+ tells you how to activate it now. Installing daedalus never touches your
200
+ shell — this command does. It is idempotent: re-running on an already
201
+ registered `~/.bashrc` writes nothing.
202
+
203
+ ```bash
204
+ daedalus init # register completion in ~/.bashrc
205
+ daedalus init --dry-run # print the block and the target, change nothing
206
+ daedalus init --bashrc FILE # a different bashrc
207
+ ```
208
+
209
+ | Argument | Default | Meaning |
210
+ | --- | --- | --- |
211
+ | `--bashrc FILE` | `~/.bashrc` | Target file for the managed hook block |
212
+ | `--dry-run` | off | Print the block and the target, change nothing |
213
+
214
+ Exit code: `3` when `register-python-argcomplete` is nowhere to be
215
+ found (reinstall daedalus — argcomplete is a declared dependency).
216
+
217
+ ### publish
218
+
219
+ `publish` releases the package itself. Guards first — clean working
220
+ tree, HEAD exactly tagged `v<version>` (the version from
221
+ `pyproject.toml`), the version not yet on PyPI, and `build` + `twine`
222
+ available in the running interpreter — then a **chained** build
223
+ (the sdist must rebuild the wheel, SPEC item 9.2.1) and
224
+ `twine check`. Without `--upload` it stops there and prints the
225
+ artifacts; with `--upload` it uploads exactly this version's sdist
226
+ and wheel. Credentials never touch the script: twine prompts or
227
+ reads `~/.pypirc` (username `__token__`, your PyPI API token).
228
+
229
+ ```bash
230
+ daedalus publish # build + check, print next step
231
+ daedalus publish --upload # ... and upload to PyPI
232
+ ```
233
+
234
+ Exit codes: `2` not run from a checkout, `3` dirty tree, `4` not
235
+ exactly tagged `v<version>`, `5` build/twine missing, `6` version
236
+ already on PyPI (or PyPI unreachable), `7` build failed, `8` twine
237
+ check failed, `9` upload failed.
238
+
239
+ ## Getting started
240
+
241
+ 1. Clone or copy this template and name the Git remote for your team.
242
+ 2. Add a script under `python/src/`, `bash/`, `powershell/`, or `batch/`
243
+ (see [SPEC layout](./SPEC.md#2-layout)); bash scripts implement the
244
+ shared `help()` interface (SPEC item 6.10).
245
+ 3. Register it in `daedalus/registry.py`, add a row to the table above,
246
+ write tests, bump `version` in `pyproject.toml`, and run
247
+ `python autotest.py`.
248
+
249
+ `hello` is the sample script: copy its file, registry entry, README row,
250
+ and tests to add your own. Unknown names exit with code 2 and suggest
251
+ close matches.
@@ -0,0 +1,243 @@
1
+ # daedalus (template)
2
+
3
+ Starter repository for daedalus:
4
+ one CLI, many small scripts, each with tests.
5
+
6
+ ```bash
7
+ daedalus <name> [args...] # run a script
8
+ daedalus <category> [category...] # list scripts in the categories (AND)
9
+ daedalus --list # list everything
10
+ ```
11
+
12
+ **[Install, usage, and development](./INSTALL.md)** ·
13
+ [SPEC](./SPEC.md) (how the repo is maintained) ·
14
+ [CHANGELOG](./CHANGELOG.md)
15
+
16
+ ## Available scripts
17
+
18
+ | Script | Type | Categories | What it does |
19
+ | --- | --- | --- | --- |
20
+ | `gpgtools` | Python | gpg | YubiKey GPG/SSH helpers: initialize (gnupg readiness check + install), initialize_yubikey (fresh machine, steps 1-4), send_pubkey (resolve key, verify possession, append to a server), store_publickey (install the key from the machine being granted access), configure_ssh (marker-managed per-host ssh block) |
21
+ | `hello` | Python | test | Prints a hello line and the daedalus version |
22
+ | `hello_bash` | Bash | test | Sample bash script through the shared help() interface |
23
+ | `init` | Python | setup | Enable tab completion for daedalus: register argcomplete in bash (appends the managed hook block to ~/.bashrc), idempotent |
24
+ | `publish` | Python | release | Release daedalus to PyPI: guarded chained build (clean tree, exact `v<version>` tag, PyPI-free version, tooling), twine check, `--upload` (credentials stay with twine) |
25
+
26
+ Run the sample script:
27
+
28
+ ```bash
29
+ daedalus hello # hello from daedalus 0.4.0
30
+ daedalus hello_bash me # hello, me (from daedalus bash)
31
+ daedalus hello_bash -h # usage from hello_bash's help()
32
+ daedalus test hello # same, through the category prefix
33
+ daedalus test # list the scripts in the 'test' category
34
+ ```
35
+
36
+ `daedalus --list` prints the version, a `script` / `type` / `categories`
37
+ table, and each description wrapped under each row.
38
+
39
+ ### gpgtools
40
+
41
+ `initialize` checks that gnupg is ready on this machine and installs
42
+ what is missing — the gnupg-only half of `initialize_yubikey`, with no
43
+ card expectations. Its use is on-site: on a bare server where you are
44
+ about to run `store_publickey --fingerprint`, this is the command that
45
+ makes the gpg-dependent sources work.
46
+
47
+ ```bash
48
+ daedalus gpgtools initialize # check gnupg, install when missing
49
+ daedalus gpgtools initialize --dry-run # already ready, or the install command
50
+ ```
51
+
52
+ | Argument | Default | Meaning |
53
+ | --- | --- | --- |
54
+ | `--dry-run` | off | Print what would happen (already ready or the install command); change nothing |
55
+
56
+ Exit codes: `0` gnupg ready (installed or already present), `2` package
57
+ install failed or gpg still unusable after it, `3` gpg missing and no
58
+ known package manager.
59
+
60
+ `initialize_yubikey` runs the fresh-machine flow for YubiKey-backed
61
+ GPG and SSH (steps 1-4 of the wiki guide): install gnupg when missing,
62
+ check the card, fetch the public key from the card's URL field, and
63
+ write the gpg-agent SSH config. Steps 5-7 are per-server and covered
64
+ by the subcommands below.
65
+
66
+ ```bash
67
+ daedalus gpgtools # overview of the subcommands
68
+ daedalus gpgtools initialize_yubikey # prepare this machine
69
+ daedalus gpgtools initialize_yubikey --dry-run # print the plan only
70
+ ```
71
+
72
+ | Argument | Default | Meaning |
73
+ | --- | --- | --- |
74
+ | `--dry-run` | off | Print the plan, write nothing |
75
+ | `--gnupg-home DIR` | `GNUPGHOME` or `~/.gnupg` | Which GnuPG home to configure |
76
+
77
+ Exit codes: `0` ready, `2` package install failed, `3` gpg missing and
78
+ no known package manager, `4` no card found, `5` public-key fetch did
79
+ not pair the keyring, `6` keyring unpaired and the card carries no URL.
80
+
81
+ `send_pubkey` covers guide steps 5-6 for one server: resolve the SSH
82
+ public key from one of five sources, prove possession of the private
83
+ half with a challenge signature (the YubiKey itself signs; PIN prompts
84
+ go to the user), then append the line to the target's
85
+ `authorized_keys` — idempotent, fingerprint-checked against stores,
86
+ and nothing is sent when verification fails.
87
+
88
+ ```bash
89
+ daedalus gpgtools send_pubkey --yubikey you@server
90
+ daedalus gpgtools send_pubkey --fingerprint <FP> you@server
91
+ daedalus gpgtools send_pubkey --url https://keys.openpgp.org/vks/v1/by-fingerprint/<FP> you@server
92
+ daedalus gpgtools send_pubkey --pubkey "ssh-ed25519 AAAA... comment" you@server
93
+ daedalus gpgtools send_pubkey --file /media/usb/yubikey_auth.pub you@server
94
+ daedalus gpgtools send_pubkey --yubikey --dry-run you@server # resolve only
95
+ ```
96
+
97
+ | Argument | Default | Meaning |
98
+ | --- | --- | --- |
99
+ | `--yubikey` | — | Key from the plugged YubiKey via gpg-agent (must be the only agent key) |
100
+ | `--url URL` | — | Armored OpenPGP public key at a URL ([A] subkey is exported) |
101
+ | `--fingerprint FP` | — | Searched: local keyring → keys.openpgp.org → keyserver.ubuntu.com |
102
+ | `--pubkey LINE` | — | The literal SSH public key line |
103
+ | `--file PATH` | — | File holding the key line, e.g. a `.pub` from a USB stick (no network, no gpg) |
104
+ | `--no-verify` | verification on | Skip the proof-of-possession signature (explicit risk acceptance) |
105
+ | `--dry-run` | off | Resolve and print the key; verify and send nothing |
106
+
107
+ Additional exit codes: `7` ssh to the target failed, `8` no source
108
+ resolved a key, `10` proof-of-possession verification failed (nothing
109
+ was sent).
110
+
111
+ `store_publickey` is the mirror for the on-site bootstrap: run it on
112
+ the machine that access is being granted *to* — a server with ssh
113
+ password authentication disabled that no key authorizes yet, where
114
+ you are logged in at the console. It resolves the same five sources
115
+ and appends the key into this machine's `authorized_keys`, so the
116
+ machine holding the YubiKey can ssh in afterwards. There is no
117
+ proof-of-possession (the private half is, by design, elsewhere);
118
+ instead both resolve-and-store subcommands print an identity block —
119
+ line, source, and the key material's SHA-256 — to compare across
120
+ machines. Existing entries are preserved, nothing is duplicated, and
121
+ directory/file modes are forced to 700/600.
122
+
123
+ ```bash
124
+ daedalus gpgtools store_publickey --file /media/usb/yubikey_auth.pub
125
+ daedalus gpgtools store_publickey --fingerprint <FP>
126
+ daedalus gpgtools store_publickey --pubkey "ssh-ed25519 AAAA... comment"
127
+ daedalus gpgtools store_publickey --file /media/usb/yubikey_auth.pub --dry-run # print only
128
+ ```
129
+
130
+ | Argument | Default | Meaning |
131
+ | --- | --- | --- |
132
+ | sources | — | Same five sources as `send_pubkey` (exactly one required) |
133
+ | `--authorized-keys FILE` | `~/.ssh/authorized_keys` | Where to install the key |
134
+ | `--dry-run` | off | Resolve and print the key; write nothing |
135
+
136
+ Additional exit codes: `8` no source resolved a key.
137
+
138
+ `configure_ssh` covers guide step 7 for one host: it writes a
139
+ marker-managed `Host <alias>` block into the ssh client config.
140
+ Outside the markers your config is preserved byte-for-byte; re-runs
141
+ replace the block (idempotent), and an unmanaged `Host` with the same
142
+ alias is refused rather than shadowed. It never connects anywhere.
143
+
144
+ ```bash
145
+ daedalus gpgtools configure_ssh --alias vault1 --hostname 203.0.113.10 --user admin
146
+ daedalus gpgtools configure_ssh --alias vault1 --dry-run # print only
147
+ daedalus gpgtools configure_ssh --alias vault1 --no-fallback # YubiKey only
148
+ ```
149
+
150
+ | Argument | Default | Meaning |
151
+ | --- | --- | --- |
152
+ | `--alias NAME` | required | The ssh Host alias to configure |
153
+ | `--hostname HOST` | the alias | HostName value |
154
+ | `--user USER` | ssh's default | User value |
155
+ | `--pubkey FILE` | `~/.ssh/yubikey_auth.pub` | Primary IdentityFile (must exist) |
156
+ | `--fallback FILE` | `~/.ssh/id_ed25519` | Fallback IdentityFile, included only when it exists |
157
+ | `--no-fallback` | off | Never add a fallback IdentityFile |
158
+ | `--config PATH` | `~/.ssh/config` | Which ssh client config to edit |
159
+
160
+ Additional exit code: `11` an unmanaged `Host` with the same alias exists in the
161
+ config (move it into the managed markers or rename the alias).
162
+
163
+ `ssh-config-summary` prints what is enabled where, read-only: one row per
164
+ managed block — alias, hostname, user, the key id (first 8 chars of the
165
+ identity's SHA256 fingerprint, material-digest fallback), and the fallback
166
+ identity. Same id on two rows means the same gpg key guards both hosts.
167
+
168
+ ```bash
169
+ daedalus gpgtools ssh-config-summary
170
+ daedalus gpgtools ssh-config-summary --config FILE
171
+ ```
172
+
173
+ | Argument | Default | Meaning |
174
+ | --- | --- | --- |
175
+ | `--config FILE` | `~/.ssh/config` | Which ssh client config to read |
176
+
177
+ ## Shell completion
178
+
179
+ Bash (and other shells argcomplete supports) completes script names and
180
+ category labels: `daedalus hel` + TAB completes `hello`, `daedalus test h` +
181
+ TAB completes `hello` inside the category, and options complete after `-`.
182
+ Run `daedalus init` once to register the hook in `~/.bashrc` (below); see
183
+ also [INSTALL](./INSTALL.md#tab-completion).
184
+
185
+ ### init
186
+
187
+ `init` is the one-time shell-side setup: it finds the
188
+ `register-python-argcomplete` that belongs to this exact daedalus
189
+ interpreter (so a pipx install wires its own venv, not some other
190
+ python), appends the hook to `~/.bashrc` between managed markers, and
191
+ tells you how to activate it now. Installing daedalus never touches your
192
+ shell — this command does. It is idempotent: re-running on an already
193
+ registered `~/.bashrc` writes nothing.
194
+
195
+ ```bash
196
+ daedalus init # register completion in ~/.bashrc
197
+ daedalus init --dry-run # print the block and the target, change nothing
198
+ daedalus init --bashrc FILE # a different bashrc
199
+ ```
200
+
201
+ | Argument | Default | Meaning |
202
+ | --- | --- | --- |
203
+ | `--bashrc FILE` | `~/.bashrc` | Target file for the managed hook block |
204
+ | `--dry-run` | off | Print the block and the target, change nothing |
205
+
206
+ Exit code: `3` when `register-python-argcomplete` is nowhere to be
207
+ found (reinstall daedalus — argcomplete is a declared dependency).
208
+
209
+ ### publish
210
+
211
+ `publish` releases the package itself. Guards first — clean working
212
+ tree, HEAD exactly tagged `v<version>` (the version from
213
+ `pyproject.toml`), the version not yet on PyPI, and `build` + `twine`
214
+ available in the running interpreter — then a **chained** build
215
+ (the sdist must rebuild the wheel, SPEC item 9.2.1) and
216
+ `twine check`. Without `--upload` it stops there and prints the
217
+ artifacts; with `--upload` it uploads exactly this version's sdist
218
+ and wheel. Credentials never touch the script: twine prompts or
219
+ reads `~/.pypirc` (username `__token__`, your PyPI API token).
220
+
221
+ ```bash
222
+ daedalus publish # build + check, print next step
223
+ daedalus publish --upload # ... and upload to PyPI
224
+ ```
225
+
226
+ Exit codes: `2` not run from a checkout, `3` dirty tree, `4` not
227
+ exactly tagged `v<version>`, `5` build/twine missing, `6` version
228
+ already on PyPI (or PyPI unreachable), `7` build failed, `8` twine
229
+ check failed, `9` upload failed.
230
+
231
+ ## Getting started
232
+
233
+ 1. Clone or copy this template and name the Git remote for your team.
234
+ 2. Add a script under `python/src/`, `bash/`, `powershell/`, or `batch/`
235
+ (see [SPEC layout](./SPEC.md#2-layout)); bash scripts implement the
236
+ shared `help()` interface (SPEC item 6.10).
237
+ 3. Register it in `daedalus/registry.py`, add a row to the table above,
238
+ write tests, bump `version` in `pyproject.toml`, and run
239
+ `python autotest.py`.
240
+
241
+ `hello` is the sample script: copy its file, registry entry, README row,
242
+ and tests to add your own. Unknown names exit with code 2 and suggest
243
+ close matches.
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env bash
2
+ # Shared interface for daedalus bash scripts (SPEC.md item 6.10).
3
+ #
4
+ # A registered bash script sources this sibling file once and ends with:
5
+ # daedalus_bash_dispatch "$@"
6
+ # The script defines help() (its usage text) and main() (its body).
7
+ # daedalus completes the help words for the script (SPEC item 3.13.5.2);
8
+ # this helper runs them: help, -h, and --help print help(), everything
9
+ # else goes to main() with the arguments unchanged.
10
+
11
+ help() {
12
+ echo "bash script error: help() is not defined (SPEC item 6.10.2)" >&2
13
+ return 2
14
+ }
15
+
16
+ main() {
17
+ echo "bash script error: main() is not defined (SPEC item 6.10.3)" >&2
18
+ return 2
19
+ }
20
+
21
+ daedalus_is_help_request() {
22
+ case "${1-}" in
23
+ help|-h|--help) return 0 ;;
24
+ *) return 1 ;;
25
+ esac
26
+ }
27
+
28
+ daedalus_bash_dispatch() {
29
+ if daedalus_is_help_request "${1:-}"; then
30
+ help
31
+ local status=$?
32
+ exit "$status"
33
+ fi
34
+ main "$@"
35
+ }
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env bash
2
+ # hello_bash: sample bash script for the shared interface (SPEC item 6.10).
3
+ #
4
+ # Run via daedalus: daedalus hello_bash [name...]
5
+ # It exists to exercise help() routing, main() dispatch, and the
6
+ # completion of the help words (SPEC item 3.13.5.2) end to end.
7
+ # shellcheck source=/dev/null
8
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/daedalus_common.sh"
9
+
10
+ help() {
11
+ cat <<'EOF'
12
+ usage: hello_bash [name...]
13
+
14
+ Prints a hello line, once per name, default "world".
15
+ EOF
16
+ }
17
+
18
+ main() {
19
+ local names=("$@")
20
+ ((${#names[@]})) || names=("world")
21
+ local name
22
+ for name in "${names[@]}"; do
23
+ echo "hello, ${name} (from daedalus bash)"
24
+ done
25
+ }
26
+
27
+ daedalus_bash_dispatch "$@"
File without changes
@@ -0,0 +1,6 @@
1
+ # Batch scripts live here
2
+
3
+ `daedalus` runs every `*.bat` in this folder (SPEC.md section 9.2);
4
+ registered scripts are installed under `daedalus/_library/batch/`.
5
+ This README keeps the folder in git and in the sdist so the
6
+ sdist can rebuild its wheel (SPEC item 9.2.1).
@@ -0,0 +1,52 @@
1
+ """daedalus: run any registered script with ``daedalus <name> [args...]``.
2
+
3
+ CLI package; see SPEC.md. On import this module also registers every
4
+ ``python/src/<folder>`` as a ``daedalus.<folder>`` package so library
5
+ scripts can import shared code in checkout and install alike
6
+ (SPEC.md section 10).
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import pathlib
11
+ import sys
12
+ import types
13
+
14
+ PACKAGE_DIR = pathlib.Path(__file__).resolve().parent
15
+ REPO_ROOT = PACKAGE_DIR.parent
16
+
17
+
18
+ def library_root(package_dir: pathlib.Path = PACKAGE_DIR) -> pathlib.Path:
19
+ """Bundled _library of an installed wheel, else the checkout root."""
20
+ installed = package_dir / "_library"
21
+ return installed if installed.is_dir() else package_dir.parent
22
+
23
+
24
+ LIBRARY_ROOT = library_root()
25
+
26
+
27
+ def register_source_folders(repo_root: pathlib.Path = REPO_ROOT) -> list[str]:
28
+ """Register python/src subfolders as daedalus.<folder> packages (SPEC item 10.3).
29
+
30
+ Each subfolder becomes an empty package whose search path is that
31
+ folder, unless a module of that name is already loaded. Returns the
32
+ names registered, in order.
33
+ """
34
+ source = repo_root / "python" / "src"
35
+ if not source.is_dir():
36
+ return []
37
+ registered: list[str] = []
38
+ for folder in sorted(source.iterdir()):
39
+ if not folder.is_dir() or folder.name.startswith((".", "_")):
40
+ continue # not a library script package (e.g. __pycache__)
41
+ name = f"daedalus.{folder.name}"
42
+ if name in sys.modules:
43
+ continue
44
+ module = types.ModuleType(name)
45
+ module.__path__ = [str(folder)]
46
+ module.__package__ = name
47
+ sys.modules[name] = module
48
+ registered.append(name)
49
+ return registered
50
+
51
+
52
+ register_source_folders(REPO_ROOT)
@@ -0,0 +1,9 @@
1
+ """Allow ``python -m daedalus``.
2
+
3
+ Module entry point.
4
+ """
5
+ import sys
6
+
7
+ from daedalus import cli
8
+
9
+ sys.exit(cli.main())