Skip to content

Commit

Permalink
Embed long help and version text in source code
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Jan 17, 2024
1 parent 427b130 commit 02cbaaa
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 14 deletions.
6 changes: 6 additions & 0 deletions crates/cli/CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ All notable changes to this project will be documented in this file.
The format is based on https://keepachangelog.com/[Keep a Changelog], and this
project adheres to https://semver.org/[Semantic Versioning].

== {compare-url}/abcrypt-cli-v0.2.10\...HEAD[Unreleased]

=== Changed

* Remove last blank line of `--version` ({pull-request-url}/225[#225])

== {compare-url}/abcrypt-cli-v0.2.9\...abcrypt-cli-v0.2.10[0.2.10] - 2024-01-07

=== Changed
Expand Down
26 changes: 20 additions & 6 deletions crates/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,31 @@ use clap_complete::Generator;

const LONG_VERSION: &str = concat!(
env!("CARGO_PKG_VERSION"),
"\n",
include_str!("assets/long-version.md")
"
Copyright (C) 2022-2024 Shun Sakai
This program is distributed under the terms of the GNU General Public License
v3.0 or later.
This is free software: you are free to change and redistribute it. There is NO
WARRANTY, to the extent permitted by law.
Report bugs to <https://github.com/sorairolake/abcrypt/issues>."
);

const AFTER_LONG_HELP: &str = include_str!("assets/after-long-help.md");
const AFTER_LONG_HELP: &str = "See `abcrypt(1)` for more details.";

const ENCRYPT_AFTER_LONG_HELP: &str = "By default, the result will be write to stdout.
See `abcrypt-encrypt(1)` for more details.";

const DECRYPT_AFTER_LONG_HELP: &str = "By default, the result will be write to stdout.
const ENCRYPT_AFTER_LONG_HELP: &str = include_str!("assets/encrypt-after-long-help.md");
See `abcrypt-decrypt(1)` for more details.";

const DECRYPT_AFTER_LONG_HELP: &str = include_str!("assets/decrypt-after-long-help.md");
const INFORMATION_AFTER_LONG_HELP: &str = "The result will be write to stdout.
const INFORMATION_AFTER_LONG_HELP: &str = include_str!("assets/information-after-long-help.md");
See `abcrypt-information(1)` for more details.";

#[derive(Debug, Parser)]
#[command(
Expand Down
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions crates/cli/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn long_version() {
.assert()
.success()
.stdout(predicate::str::contains(include_str!(
"../src/assets/long-version.md"
"assets/long-version.md"
)));
}

Expand All @@ -62,7 +62,7 @@ fn after_long_help() {
.assert()
.success()
.stdout(predicate::str::contains(include_str!(
"../src/assets/after-long-help.md"
"assets/after-long-help.md"
)));
}

Expand Down Expand Up @@ -425,7 +425,7 @@ fn long_version_for_encrypt_command() {
.assert()
.success()
.stdout(predicate::str::contains(include_str!(
"../src/assets/long-version.md"
"assets/long-version.md"
)));
}

Expand All @@ -437,7 +437,7 @@ fn after_long_help_for_encrypt_command() {
.assert()
.success()
.stdout(predicate::str::contains(include_str!(
"../src/assets/encrypt-after-long-help.md"
"assets/encrypt-after-long-help.md"
)));
}

Expand Down Expand Up @@ -496,7 +496,7 @@ fn long_version_for_decrypt_command() {
.assert()
.success()
.stdout(predicate::str::contains(include_str!(
"../src/assets/long-version.md"
"assets/long-version.md"
)));
}

Expand All @@ -508,7 +508,7 @@ fn after_long_help_for_decrypt_command() {
.assert()
.success()
.stdout(predicate::str::contains(include_str!(
"../src/assets/decrypt-after-long-help.md"
"assets/decrypt-after-long-help.md"
)));
}

Expand Down Expand Up @@ -566,7 +566,7 @@ fn long_version_for_information_command() {
.assert()
.success()
.stdout(predicate::str::contains(include_str!(
"../src/assets/long-version.md"
"assets/long-version.md"
)));
}

Expand All @@ -578,6 +578,6 @@ fn after_long_help_for_information_command() {
.assert()
.success()
.stdout(predicate::str::contains(include_str!(
"../src/assets/information-after-long-help.md"
"assets/information-after-long-help.md"
)));
}

0 comments on commit 02cbaaa

Please sign in to comment.