diff options
| author | Leitwolf11 | 2026-11-05 06:29:20 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-11-05 06:29:20 +0300 |
| commit | 52490ff852f3d72ce9c9eb76898080223e9e17fd (patch) | |
| tree | 4dd64d7cdce703fa15956dfa51bf587b3f397153 /Sources/Help.cpp | |
| download | tazelish-52490ff852f3d72ce9c9eb76898080223e9e17fd.tar.gz | |
Start Tazelish with its command line and version files
Tazelish installs Tazel and chooses which version of it runs, for those
who use Tazel alone. This first part holds everything that needs no
download:
- Versions: MAJOR.SEMIMAJOR.MINOR.PATCH without leading zeros,
unstable, nightly, and YYYY-MM-DD-unstable or -nightly with a date
the calendar has.
- The command line, read by hand into a typed command: install, use
and default with --force before or after the version, self
update|remove|purge, and help with or without a command. A wrong
command line ends with exit code 2.
- tazelish.txt and config.txt: the nearest tazelish.txt in the current
folder or above it comes first, then $HOME/.tazelish/config.txt or
%USERPROFILE%\.tazelish\config.txt. use and default refuse to write
over a file that exists unless --force is given.
install and self download from static.tazel.net, which this build does
not do; they say so and end with exit code 1.
C++17 with fmt, tested with Catch3, built by Bazel (clang-cl on
Windows, with the rules_cc patch the Tala repository carries). The code
throws no exceptions and builds with warnings as errors; the tests
leave out -Wconversion, which the headers of Catch3 do not pass. CI
tests on Linux, macOS and Windows.
Diffstat (limited to 'Sources/Help.cpp')
| -rw-r--r-- | Sources/Help.cpp | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/Sources/Help.cpp b/Sources/Help.cpp new file mode 100644 index 0000000..9febd19 --- /dev/null +++ b/Sources/Help.cpp @@ -0,0 +1,105 @@ +// SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com> +// SPDX-License-Identifier: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-2.0 + +#include "Progmasoft/Tazelish/Help.hpp" + +namespace Progmasoft::Tazelish +{ + namespace + { + + constexpr std::string_view kGeneral + = R"(Tazelish installs Tazel and chooses which version of it runs. + +Usage: tazelish <command> [arguments] + +Commands: + install <version> installs a version of Tazel + use [--force] <version> writes the version to ./tazelish.txt + default [--force] <version> + writes the version to the config.txt of the user + self update updates Tazelish + self remove removes Tazelish and the versions it installed + self purge also removes its settings, downloads and logs + help [command] prints this help, or the help of one command + +A version is MAJOR.SEMIMAJOR.MINOR.PATCH, unstable, nightly, +YYYY-MM-DD-unstable or YYYY-MM-DD-nightly. + +Exit codes: 0 success, 1 the work failed, 2 the command line was wrong. +)"; + + constexpr std::string_view kInstall + = R"(Usage: tazelish install <version> + +Installs a version of Tazel: + tazelish install 0.4.0.3 a release + tazelish install unstable the newest unstable build + tazelish install nightly the newest nightly build + tazelish install 2026-11-05-unstable the unstable build of a day + tazelish install 2026-11-05-nightly the nightly build of a day +)"; + + constexpr std::string_view kUse + = R"(Usage: tazelish use [--force] <version> + +Writes the version to tazelish.txt in the current folder, so Tazel runs that +version there and in the folders below. The nearest tazelish.txt comes before +the config.txt of the user. + +An existing tazelish.txt is an error; --force writes over it. +)"; + + constexpr std::string_view kDefault + = R"(Usage: tazelish default [--force] <version> + +Writes the version to the config.txt of the user, the version Tazel runs where +no tazelish.txt names one: + $HOME/.tazelish/config.txt on Linux and macOS + %USERPROFILE%\.tazelish\config.txt on Windows + +An existing config.txt is an error; --force writes over it. +)"; + + constexpr std::string_view kSelf + = R"(Usage: tazelish self update|remove|purge + + update updates Tazelish + remove removes Tazelish, the versions of Tazel it installed and the PATH + entries it added + purge does what remove does and also deletes the config.txt, the + downloads and the logs of Tazelish +)"; + + constexpr std::string_view kHelp = R"(Usage: tazelish help [command] + +Prints the help of Tazelish, or the help of one command: install, use, +default, self or help. +)"; + + } // namespace + + std::string_view + HelpText(std::optional<Topic> topic) + { + if (!topic) + { + return kGeneral; + } + switch (*topic) + { + case Topic::kInstall: + return kInstall; + case Topic::kUse: + return kUse; + case Topic::kDefault: + return kDefault; + case Topic::kSelf: + return kSelf; + case Topic::kHelp: + return kHelp; + } + return kGeneral; + } + +} // namespace Progmasoft::Tazelish |