feat(cli): add yay/paru-style command parsing
This commit is contained in:
@@ -0,0 +1,363 @@
|
||||
Warning
|
||||
Warning ## Warning for package tofu ##
|
||||
Warning
|
||||
Warning The following compiler flags have been specified in the package description
|
||||
Warning file. They are handled by DUB and direct use in packages is discouraged.
|
||||
Warning Alternatively, you can set the DFLAGS environment variable to pass custom flags
|
||||
Warning to the compiler, or use one of the suggestions below:
|
||||
Warning
|
||||
Warning warningsAsErrors: Use "buildRequirements" to control the warning level
|
||||
Warning
|
||||
Generating test runner configuration 'tofu-test-application' for 'application' (executable).
|
||||
Warning Excluding main source file src/main.d from test.
|
||||
Starting Performing "unittest" build using /usr/bin/dmd for x86_64.
|
||||
Up-to-date toml 1.0.0: target for configuration [library] is up to date.
|
||||
Up-to-date tofu ~main: target for configuration [tofu-test-application] is up to date.
|
||||
Finished To force a rebuild of up-to-date targets, run again with --force
|
||||
Running tofu-test-application
|
||||
zeta-makepkg: building hello...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phasezeta-makepkg: building hello...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phasezeta-makepkg: building hello...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phasezeta-makepkg: building hello...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phasedonezeta-makepkg: building depA...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phasezeta-makepkg: building depB...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phasezeta-makepkg: building target...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phasezeta-makepkg: building depA...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phase[31merror[0m build failed for depA: build failed for depA:
|
||||
zeta-makepkg: building depA...
|
||||
zeta-makepkg: configure phase
|
||||
zeta-makepkg: build phase
|
||||
zeta-makepkg: install phase
|
||||
zeta-makepkg: building pkg...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phase[31merror[0m build failed for noexist: recipe not found at /tmp/tofu-test-build-buildall-norecipe-221389/nonexistent.recipe
|
||||
[33mwarn corrupted cache for pkg: Found 'h' when expecting 'r'. (Line 1:2)[0m
|
||||
Warning: malformed TOML config at /tmp/tofu-test-config-bad-221389.toml: Invalid table key declaration (2:0)
|
||||
Warning: invalid TOFU_DEFAULT_JOBS 'not-a-number', using default 1
|
||||
[33mwarn removing stale lock (PID 99999999 not alive)[0m
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] "GET /recipes/hello/hello.recipe HTTP/1.1" 200 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] "GET /recipes/hello/package.lua HTTP/1.1" 200 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] "GET /recipes/hello/build.sh HTTP/1.1" 200 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] code 404, message File not found
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] "GET /recipes/hello/hello.recipe HTTP/1.1" 404 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] "GET /recipes/hello/hello.recipe HTTP/1.1" 200 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] code 404, message File not found
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] "GET /recipes/hello/package.lua HTTP/1.1" 404 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] code 404, message File not found
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] "GET /recipes/hello/build.sh HTTP/1.1" 404 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] "GET /recipes/hello/scripts/build.sh HTTP/1.1" 200 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] "GET /recipes/hello/hello.recipe HTTP/1.1" 200 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] code 404, message File not found
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] "GET /recipes/hello/package.lua HTTP/1.1" 404 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] code 404, message File not found
|
||||
127.0.0.1 - - [08/Aug/2026 18:16:30] "GET /recipes/hello/build.sh HTTP/1.1" 404 -
|
||||
[33mwarn skipping index entry with empty name[0m
|
||||
[33mwarn skipping index entry with empty name[0m
|
||||
[33mwarn skipping index entry 'badpool': invalid pool 'bad_pool_value'[0m
|
||||
[2m . checking binary firefox ...[0m
|
||||
- binary firefox-2.1.0 satisfies firefox>=2.0
|
||||
[2m . checking binary libfoo ...[0m
|
||||
- binary libfoo-1.9 does not satisfy libfoo>=2.0
|
||||
[2m . checking binary noexist ...[0m
|
||||
[2m . checking binary brokenpkg ...[0m
|
||||
[2m . checking binary badpkg ...[0m
|
||||
[2m . checking binary testpkg ...[0m
|
||||
- binary testpkg-2.1.0 satisfies testpkg
|
||||
[36m==> ──── building depA (1/3) ────[0m
|
||||
[32m ok depA[0m
|
||||
[36m==> ──── building depB (2/3) ────[0m
|
||||
[32m ok depB[0m
|
||||
[36m==> ──── building target (3/3) ────[0m
|
||||
[32m ok target[0m
|
||||
[36m==> ──── building depA (1/3) ────[0m
|
||||
- nothing to build
|
||||
[36m==> ──── building pkg (1/1) ────[0m
|
||||
- pkg already built, skipping
|
||||
[36m==> ──── building pkg (1/1) ────[0m
|
||||
[32m ok pkg[0m
|
||||
[36m==> fetching recipe hello[0m
|
||||
[2m . downloading hello.recipe[0m
|
||||
[2m . downloading package.lua[0m
|
||||
[2m . downloading build.sh[0m
|
||||
[32m ok recipe hello downloaded[0m
|
||||
[36m==> fetching recipe hello[0m
|
||||
[2m . downloading hello.recipe[0m
|
||||
[36m==> fetching recipe hello[0m
|
||||
[2m . downloading hello.recipe[0m
|
||||
[2m . downloading package.lua[0m
|
||||
- no package.lua for hello (optional manifest)
|
||||
[2m . downloading build.sh[0m
|
||||
- no build.sh for hello (optional build script)
|
||||
[2m . custom build system: fetching scripts/build.sh[0m
|
||||
[32m ok recipe hello downloaded[0m
|
||||
[36m==> fetching recipe hello[0m
|
||||
[2m . downloading hello.recipe[0m
|
||||
[2m . downloading package.lua[0m
|
||||
- no package.lua for hello (optional manifest)
|
||||
[2m . downloading build.sh[0m
|
||||
- no build.sh for hello (optional build script)
|
||||
[32m ok recipe hello downloaded[0m
|
||||
[36m==> fetching recipe hello[0m
|
||||
[2m . downloading hello.recipe[0m
|
||||
[2m . fetching index http://127.0.0.1:43823//index.lua[0m
|
||||
[32m ok index loaded: 3 packages[0m
|
||||
[2m . fetching index http://127.0.0.1:41319//index.lua[0m
|
||||
[2m . fetching index http://127.0.0.1:52719//index.lua[0m
|
||||
[2m . fetching index http://127.0.0.1:42909//index.lua[0m
|
||||
[2m . fetching index http://127.0.0.1:46941//index.lua[0m
|
||||
[32m ok index loaded: 0 packages[0m
|
||||
[2m . fetching index http://127.0.0.1:56281//index.lua[0m
|
||||
[32m ok index loaded: 1 packages[0m
|
||||
[2m . fetching index http://127.0.0.1:48155//index.lua[0m
|
||||
[32m ok index loaded: 2 packages[0m
|
||||
[2m . fetching index http://127.0.0.1:53239//index.lua[0m
|
||||
[2m . fetching index http://127.0.0.1:51665//index.lua[0m
|
||||
[32m ok index loaded: 1 packages[0m
|
||||
installing package...error: build failedreason: missing dependencytestpkg-2.1 is already installed -- use -ReProvide to reinstall - already installed — skipping
|
||||
[32m ok installed A with 2 dependencies[0m
|
||||
- nothing to install
|
||||
install failed: conflict detectedtestpkg-2.1 is already installed -- use -ReProvide to reinstall[33mwarn corrupted installed state at /tmp/tofu-test-state-corrupt-221389/installed.json: Found 'h' when expecting 'r'. (Line 1:2)[0m
|
||||
[33mwarn corrupted installed state at /tmp/tofu-test-state-corrupt-221389/installed.json: Found 'h' when expecting 'r'. (Line 1:2)[0m
|
||||
16 modules passed unittests
|
||||
- already installed — skipping
|
||||
[32m ok installed A with 0 dependencies[0m
|
||||
- binary libfoo-2.1 satisfies libfoo>=2.0
|
||||
- libfoo: binary 1.9 too old, building from recipe
|
||||
- libfoo: binary 1.9 too old, building from recipe
|
||||
- binary libbar-3.0 satisfies libbar (unconstrained)
|
||||
- libbaz: no binary available, building from recipe
|
||||
- binary libfoo-1.5 satisfies libfoo>=1.0
|
||||
- libfoo: binary 1.5 too old, building from recipe
|
||||
- binary parentA-1.5 satisfies parentA (unconstrained)
|
||||
- binary parentB-1.5 satisfies parentB (unconstrained)
|
||||
[36m==> generating build plan[0m
|
||||
- + C (recipe)
|
||||
- + A (recipe)
|
||||
[32m ok build plan: 2 packages[0m
|
||||
[36m==> generating build plan[0m
|
||||
- recipe libfoo not in cache, re-fetching
|
||||
- + libfoo (recipe)
|
||||
[32m ok build plan: 1 packages[0m
|
||||
[36m==> generating build plan[0m
|
||||
[36m==> generating build plan[0m
|
||||
- nothing to build (all binary)
|
||||
[36m==> generating build plan[0m
|
||||
- + mypkg (recipe)
|
||||
[32m ok build plan: 1 packages[0m
|
||||
[36m==> generating build plan[0m
|
||||
- + libfoo (recipe)
|
||||
- + mypkg (recipe)
|
||||
[32m ok build plan: 2 packages[0m
|
||||
Warning
|
||||
Warning ## Warning for package tofu ##
|
||||
Warning
|
||||
Warning The following compiler flags have been specified in the package description
|
||||
Warning file. They are handled by DUB and direct use in packages is discouraged.
|
||||
Warning Alternatively, you can set the DFLAGS environment variable to pass custom flags
|
||||
Warning to the compiler, or use one of the suggestions below:
|
||||
Warning
|
||||
Warning warningsAsErrors: Use "buildRequirements" to control the warning level
|
||||
Warning
|
||||
Starting Performing "debug" build using /usr/bin/dmd for x86_64.
|
||||
Up-to-date toml 1.0.0: target for configuration [library] is up to date.
|
||||
Building tofu ~main: building configuration [application]
|
||||
src/main.d(26,8): Error: module `tofu.cli` import `helpText` not found
|
||||
import tofu.cli : Command, parseArgs, helpText;
|
||||
^
|
||||
Error /usr/bin/dmd failed with exit code 1.
|
||||
Warning
|
||||
Warning ## Warning for package tofu ##
|
||||
Warning
|
||||
Warning The following compiler flags have been specified in the package description
|
||||
Warning file. They are handled by DUB and direct use in packages is discouraged.
|
||||
Warning Alternatively, you can set the DFLAGS environment variable to pass custom flags
|
||||
Warning to the compiler, or use one of the suggestions below:
|
||||
Warning
|
||||
Warning warningsAsErrors: Use "buildRequirements" to control the warning level
|
||||
Warning
|
||||
Generating test runner configuration 'tofu-test-application' for 'application' (executable).
|
||||
Warning Excluding main source file src/main.d from test.
|
||||
Starting Performing "unittest" build using /usr/bin/dmd for x86_64.
|
||||
Up-to-date toml 1.0.0: target for configuration [library] is up to date.
|
||||
Building tofu ~main: building configuration [tofu-test-application]
|
||||
Linking tofu-test-application
|
||||
Finished To force a rebuild of up-to-date targets, run again with --force
|
||||
Running tofu-test-application
|
||||
zeta-makepkg: building hello...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phasezeta-makepkg: building hello...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phasezeta-makepkg: building hello...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phasezeta-makepkg: building hello...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phasedonezeta-makepkg: building depA...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phasezeta-makepkg: building depB...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phasezeta-makepkg: building target...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phasezeta-makepkg: building depA...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phase[31merror[0m build failed for depA: build failed for depA:
|
||||
zeta-makepkg: building depA...
|
||||
zeta-makepkg: configure phase
|
||||
zeta-makepkg: build phase
|
||||
zeta-makepkg: install phase
|
||||
zeta-makepkg: building pkg...zeta-makepkg: configure phasezeta-makepkg: build phasezeta-makepkg: install phase[31merror[0m build failed for noexist: recipe not found at /tmp/tofu-test-build-buildall-norecipe-222376/nonexistent.recipe
|
||||
[33mwarn corrupted cache for pkg: Found 'h' when expecting 'r'. (Line 1:2)[0m
|
||||
Warning: malformed TOML config at /tmp/tofu-test-config-bad-222376.toml: Invalid table key declaration (2:0)
|
||||
Warning: invalid TOFU_DEFAULT_JOBS 'not-a-number', using default 1
|
||||
[33mwarn removing stale lock (PID 99999999 not alive)[0m
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:16] "GET /recipes/hello/hello.recipe HTTP/1.1" 200 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:16] "GET /recipes/hello/package.lua HTTP/1.1" 200 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:16] "GET /recipes/hello/build.sh HTTP/1.1" 200 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:16] code 404, message File not found
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:16] "GET /recipes/hello/hello.recipe HTTP/1.1" 404 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:16] "GET /recipes/hello/hello.recipe HTTP/1.1" 200 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:16] code 404, message File not found
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:16] "GET /recipes/hello/package.lua HTTP/1.1" 404 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:16] code 404, message File not found
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:16] "GET /recipes/hello/build.sh HTTP/1.1" 404 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:16] "GET /recipes/hello/scripts/build.sh HTTP/1.1" 200 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:17] "GET /recipes/hello/hello.recipe HTTP/1.1" 200 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:17] code 404, message File not found
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:17] "GET /recipes/hello/package.lua HTTP/1.1" 404 -
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:17] code 404, message File not found
|
||||
127.0.0.1 - - [08/Aug/2026 18:17:17] "GET /recipes/hello/build.sh HTTP/1.1" 404 -
|
||||
[33mwarn skipping index entry with empty name[0m
|
||||
[33mwarn skipping index entry with empty name[0m
|
||||
[33mwarn skipping index entry 'badpool': invalid pool 'bad_pool_value'[0m
|
||||
[2m . checking binary firefox ...[0m
|
||||
- binary firefox-2.1.0 satisfies firefox>=2.0
|
||||
[2m . checking binary libfoo ...[0m
|
||||
- binary libfoo-1.9 does not satisfy libfoo>=2.0
|
||||
[2m . checking binary noexist ...[0m
|
||||
[2m . checking binary brokenpkg ...[0m
|
||||
[2m . checking binary badpkg ...[0m
|
||||
[2m . checking binary testpkg ...[0m
|
||||
- binary testpkg-2.1.0 satisfies testpkg
|
||||
[36m==> ──── building depA (1/3) ────[0m
|
||||
[32m ok depA[0m
|
||||
[36m==> ──── building depB (2/3) ────[0m
|
||||
[32m ok depB[0m
|
||||
[36m==> ──── building target (3/3) ────[0m
|
||||
[32m ok target[0m
|
||||
[36m==> ──── building depA (1/3) ────[0m
|
||||
- nothing to build
|
||||
[36m==> ──── building pkg (1/1) ────[0m
|
||||
- pkg already built, skipping
|
||||
[36m==> ──── building pkg (1/1) ────[0m
|
||||
[32m ok pkg[0m
|
||||
[36m==> fetching recipe hello[0m
|
||||
[2m . downloading hello.recipe[0m
|
||||
[2m . downloading package.lua[0m
|
||||
[2m . downloading build.sh[0m
|
||||
[32m ok recipe hello downloaded[0m
|
||||
[36m==> fetching recipe hello[0m
|
||||
[2m . downloading hello.recipe[0m
|
||||
[36m==> fetching recipe hello[0m
|
||||
[2m . downloading hello.recipe[0m
|
||||
[2m . downloading package.lua[0m
|
||||
- no package.lua for hello (optional manifest)
|
||||
[2m . downloading build.sh[0m
|
||||
- no build.sh for hello (optional build script)
|
||||
[2m . custom build system: fetching scripts/build.sh[0m
|
||||
[32m ok recipe hello downloaded[0m
|
||||
[36m==> fetching recipe hello[0m
|
||||
[2m . downloading hello.recipe[0m
|
||||
[2m . downloading package.lua[0m
|
||||
- no package.lua for hello (optional manifest)
|
||||
[2m . downloading build.sh[0m
|
||||
- no build.sh for hello (optional build script)
|
||||
[32m ok recipe hello downloaded[0m
|
||||
[36m==> fetching recipe hello[0m
|
||||
[2m . downloading hello.recipe[0m
|
||||
[2m . fetching index http://127.0.0.1:56427//index.lua[0m
|
||||
[32m ok index loaded: 3 packages[0m
|
||||
[2m . fetching index http://127.0.0.1:46879//index.lua[0m
|
||||
[2m . fetching index http://127.0.0.1:53329//index.lua[0m
|
||||
[2m . fetching index http://127.0.0.1:46323//index.lua[0m
|
||||
[2m . fetching index http://127.0.0.1:59185//index.lua[0m
|
||||
[32m ok index loaded: 0 packages[0m
|
||||
[2m . fetching index http://127.0.0.1:50481//index.lua[0m
|
||||
[32m ok index loaded: 1 packages[0m
|
||||
[2m . fetching index http://127.0.0.1:35515//index.lua[0m
|
||||
[32m ok index loaded: 2 packages[0m
|
||||
[2m . fetching index http://127.0.0.1:36507//index.lua[0m
|
||||
[2m . fetching index http://127.0.0.1:44385//index.lua[0m
|
||||
[32m ok index loaded: 1 packages[0m
|
||||
installing package...error: build failedreason: missing dependencytestpkg-2.1 is already installed -- use -ReProvide to reinstall - already installed — skipping
|
||||
[32m ok installed A with 2 dependencies[0m
|
||||
- nothing to install
|
||||
install failed: conflict detectedtestpkg-2.1 is already installed -- use -ReProvide to reinstall[33mwarn corrupted installed state at /tmp/tofu-test-state-corrupt-222376/installed.json: Found 'h' when expecting 'r'. (Line 1:2)[0m
|
||||
[33mwarn corrupted installed state at /tmp/tofu-test-state-corrupt-222376/installed.json: Found 'h' when expecting 'r'. (Line 1:2)[0m
|
||||
16 modules passed unittests
|
||||
- already installed — skipping
|
||||
[32m ok installed A with 0 dependencies[0m
|
||||
- binary libfoo-2.1 satisfies libfoo>=2.0
|
||||
- libfoo: binary 1.9 too old, building from recipe
|
||||
- libfoo: binary 1.9 too old, building from recipe
|
||||
- binary libbar-3.0 satisfies libbar (unconstrained)
|
||||
- libbaz: no binary available, building from recipe
|
||||
- binary libfoo-1.5 satisfies libfoo>=1.0
|
||||
- libfoo: binary 1.5 too old, building from recipe
|
||||
- binary parentA-1.5 satisfies parentA (unconstrained)
|
||||
- binary parentB-1.5 satisfies parentB (unconstrained)
|
||||
[36m==> generating build plan[0m
|
||||
- + C (recipe)
|
||||
- + A (recipe)
|
||||
[32m ok build plan: 2 packages[0m
|
||||
[36m==> generating build plan[0m
|
||||
- recipe libfoo not in cache, re-fetching
|
||||
- + libfoo (recipe)
|
||||
[32m ok build plan: 1 packages[0m
|
||||
[36m==> generating build plan[0m
|
||||
[36m==> generating build plan[0m
|
||||
- nothing to build (all binary)
|
||||
[36m==> generating build plan[0m
|
||||
- + mypkg (recipe)
|
||||
[32m ok build plan: 1 packages[0m
|
||||
[36m==> generating build plan[0m
|
||||
- + libfoo (recipe)
|
||||
- + mypkg (recipe)
|
||||
[32m ok build plan: 2 packages[0m
|
||||
=== BUILD ===
|
||||
Warning
|
||||
Warning ## Warning for package tofu ##
|
||||
Warning
|
||||
Warning The following compiler flags have been specified in the package description
|
||||
Warning file. They are handled by DUB and direct use in packages is discouraged.
|
||||
Warning Alternatively, you can set the DFLAGS environment variable to pass custom flags
|
||||
Warning to the compiler, or use one of the suggestions below:
|
||||
Warning
|
||||
Warning warningsAsErrors: Use "buildRequirements" to control the warning level
|
||||
Warning
|
||||
Starting Performing "debug" build using /usr/bin/dmd for x86_64.
|
||||
Up-to-date toml 1.0.0: target for configuration [library] is up to date.
|
||||
Building tofu ~main: building configuration [application]
|
||||
src/main.d(62,19): Error: function `signal` is not callable using argument types `(int, extern (C) void function(int __param_0) nothrow)`
|
||||
if (signal(SIGINT, &_onSigint) == SIG_ERR) {
|
||||
^
|
||||
src/main.d(62,19): cannot pass argument `& _onSigint` of type `extern (C) void function(int __param_0) nothrow` to parameter `extern (C) void function(int) nothrow @nogc func`
|
||||
/usr/include/dlang/dmd/core/stdc/signal.d(75,9): `core.stdc.signal.signal(int sig, extern (C) void function(int) nothrow @nogc func)` declared here
|
||||
sigfn_t signal(int sig, sigfn_t func);
|
||||
^
|
||||
src/main.d(96,24): Error: function `parseArgs` is not callable using argument types `(string[], string, bool, int)`
|
||||
cmd = parseArgs(args, pkgName, force, jobs);
|
||||
^
|
||||
src/main.d(96,24): expected 1 argument(s), not 4
|
||||
src/tofu/cli.d(101,12): `tofu.cli.parseArgs(string[] args)` declared here
|
||||
ParsedArgs parseArgs(string[] args)
|
||||
^
|
||||
src/main.d(105,14): Error: no property `Help` for type `Command`. Did you mean `Command.help` ?
|
||||
case Command.Help:
|
||||
^
|
||||
src/tofu/cli.d(20,1): enum `Command` defined here
|
||||
enum Command
|
||||
^
|
||||
src/main.d(119,14): Error: no property `Install` for type `Command`. Did you mean `Command.install` ?
|
||||
case Command.Install:
|
||||
^
|
||||
src/tofu/cli.d(20,1): enum `Command` defined here
|
||||
enum Command
|
||||
^
|
||||
src/main.d(123,14): Error: no property `Search` for type `Command`. Did you mean `Command.search` ?
|
||||
case Command.Search:
|
||||
^
|
||||
src/tofu/cli.d(20,1): enum `Command` defined here
|
||||
enum Command
|
||||
^
|
||||
src/main.d(127,14): Error: no property `Upgrade` for type `Command`. Did you mean `Command.upgrade` ?
|
||||
case Command.Upgrade:
|
||||
^
|
||||
src/tofu/cli.d(20,1): enum `Command` defined here
|
||||
enum Command
|
||||
^
|
||||
src/main.d(131,14): Error: no property `Remove` for type `Command`
|
||||
case Command.Remove:
|
||||
^
|
||||
src/tofu/cli.d(20,1): enum `Command` defined here
|
||||
enum Command
|
||||
^
|
||||
src/main.d(135,14): Error: no property `Info` for type `Command`. Did you mean `Command.info` ?
|
||||
case Command.Info:
|
||||
^
|
||||
src/tofu/cli.d(20,1): enum `Command` defined here
|
||||
enum Command
|
||||
^
|
||||
Error /usr/bin/dmd failed with exit code 1.
|
||||
@@ -792,3 +792,68 @@ The sandbox test (test 2) creates a sentinel file, serves an index containing `o
|
||||
|
||||
### Pre-existing breakage note
|
||||
- `src/tofu/cli.d` and `src/tofu/errors.d` are pre-existing broken modules from parallel agent tasks (after task 17). They block `dub build` and `dub test` (without `.skip` rename). These are outside the scope of task 18.
|
||||
|
||||
---
|
||||
|
||||
## Task 19 — `tofu.cli` (yay/paru-style command-line parsing)
|
||||
|
||||
### Architecture
|
||||
- Module `tofu.cli` — standalone CLI parser, no dependencies on other tofu modules.
|
||||
- Imports: `std.conv` (to, ConvException), `std.string` (startsWith, indexOf).
|
||||
- Manual parsing — no framework dependency. Designed for single-pass argv scanning.
|
||||
|
||||
### Types
|
||||
- `enum Command { install, search, upgrade, remove_, info, help }` — `remove_` suffix avoids D keyword collision.
|
||||
- `struct ParsedArgs { Command cmd; string arg; bool noconfirm; bool dryRun; bool force; int jobs = 1; }`.
|
||||
- `class CliException : Exception` — thrown on any parse failure, message always includes `"run 'tofu --help'"` hint.
|
||||
|
||||
### Parsing algorithm (single-pass)
|
||||
1. **Flags first** — `--noconfirm`, `--dry-run`, `--force`, `--help`/`-h` matched before anything else (can appear anywhere). `-h`/`--help` overrides any previously-set command.
|
||||
2. **-j flag** — two forms: `-j<N>` (attached) or `-j <N>` (next arg). Validates positive int via `parsePositiveInt()`. Throws `CliException` if missing argument or non-positive.
|
||||
3. **Command tokens** — only the first one wins (`!cmdSet` guard). Matches exact forms: `-Syu` (upgrade), `-Ss` (search), `-Si` (info), `-S` (install), `-R` (remove). Unknown `-X` tokens before a command → `CliException`.
|
||||
4. **Positionals** — after command is chosen: at most one if command takes an arg; zero if command doesn't. Extra positionals → `CliException("too many arguments")`. Unexpected args on no-arg commands → `CliException("unexpected argument")`.
|
||||
5. **Post-scan** — no command → `"no command given"`. Command needs arg but none provided → `"command requires an argument"`.
|
||||
|
||||
### `@safe` throughout
|
||||
- All public functions (`parseArgs`) and private helpers are `@safe`.
|
||||
- `parsePositiveInt` uses try-catch on `std.conv.to!int` — `ConvException` caught and re-thrown as `CliException`.
|
||||
- No `@trusted` blocks needed (no filesystem or system calls).
|
||||
|
||||
### `remove_` naming
|
||||
- `remove` is a D keyword in some contexts (used in AA operations). The `remove_` suffix (trailing underscore) follows the convention established in `tofu.types` (`BuildResult.failed_`). Callers use `Command.remove_`.
|
||||
|
||||
### `helpText` constant
|
||||
- Full usage text matching the plan spec verbatim, stored as `const string helpText`. Named `helpText` (not `usage`) for compatibility with `main.d` which imports `helpText` from `tofu.cli`.
|
||||
|
||||
### Test cases (12/12 pass)
|
||||
1. `-S neovim` → install, arg=neovim ✓
|
||||
2. `-Ss editor` → search, arg=editor ✓
|
||||
3. `-Syu` → upgrade, arg="" ✓
|
||||
4. `-R neovim` → remove ✓
|
||||
5. `-Si neovim` → info ✓
|
||||
6. `--help` and `-h` → help ✓
|
||||
7. empty → CliException "no command given" ✓
|
||||
8. `-S neovim --noconfirm --dry-run -j4` → all flags set ✓
|
||||
9. `-S neovim -j0` → CliException (must be positive) ✓
|
||||
10. unknown flag `-Z` → CliException ✓
|
||||
11. `-S neovim extra` → too many arguments ✓
|
||||
12. `-Ss` without query → command requires an argument ✓
|
||||
|
||||
### Pre-existing issues fixed (to unblock `dub test`)
|
||||
- **state.d L203**: Conflicting `@safe`/`@trusted` on `makeTestConfig()` — removed `@safe`.
|
||||
- **state.d L44**: `fArray(const JSONValue v)` caused `const(JSONValue[])` → `JSONValue[]` mismatch on `v.array` — removed `const`.
|
||||
- **errors.d L31**: `core.sys.posix.errno` does not exist on DMD 2.112. `ESRCH` lives in `core.stdc.errno` — merged both imports into `import core.stdc.errno : ESRCH, errno;`.
|
||||
- **errors.d L190**: `pid_t` undefined — added `import core.sys.posix.sys.types : pid_t;` in `version(Posix)`.
|
||||
- **errors.d L508**: Missing `indexOf` on string — added `import std.string : indexOf;`.
|
||||
|
||||
### `dub build` / `main.d` integration note
|
||||
- `dub test` passes — all 16 modules (including cli.d's 12 unittests) pass.
|
||||
- `dub build` fails because `main.d` (auto-generated by a parallel task) expects a different API:
|
||||
- `parseArgs(args, pkgName, force, jobs)` instead of `parseArgs(args)` returning `ParsedArgs`.
|
||||
- Capitalised enum members (`Command.Help`, `Command.Install`, ...) instead of lowercase.
|
||||
- `signal` handler missing `@nogc` attribute.
|
||||
- This is intentional per the plan — main.d wiring happens in task 20 (the first command implementation task). The cli.d module itself is correct and fully tested.
|
||||
|
||||
### Build verified
|
||||
- `dub test` passes — all 16 modules with warnings-as-errors.
|
||||
- Evidence logged to `.omo/evidence/task-19-tofu-core.log`.
|
||||
|
||||
Reference in New Issue
Block a user