pub const VERSION: &str = env!("CARGO_PKG_VERSION");
const DOCS_URL: &str = "https://github.com/mijowi/edamame/blob/main/docs/getting-started.md";
const ISSUES_URL: &str = "https://github.com/mijowi/edamame/issues";
pub const USAGE: &str =
"USAGE:\n edamame [OPTIONS] [FILE[#SECTION]]\n edamame --diff <OLD> <NEW>\n\nTry 'edamame --help'.";
pub fn version_line() -> String {
format!("edamame {VERSION}")
}
pub fn help_text() -> String {
format!(
"\
edamame {VERSION}
A fast TUI Markdown editor and viewer
USAGE:
edamame [OPTIONS] [FILE[#SECTION]]
edamame --diff <OLD> <NEW>
ARGS:
<FILE> Markdown file to open (empty buffer if omitted).
Append #section to open it at that heading, e.g.
edamame notes.md#getting-started
OPTIONS:
-h, --help Print this help
-V, --version Print the installed version
--doctor Print version, system, and terminal diagnostics;
include this output when reporting an issue
--diff Review two Markdown files side by side, read-only.
A pair that isn't Markdown is skipped. Intended as
a git difftool; see docs/editing.md
--no-config Ignore ~/.config/edamame for the whole run: built-in
defaults only, and no settings saved
--log Write a debug log for this run
-- Treat every later argument as the file name
Documentation: {DOCS_URL}
Report an issue: {ISSUES_URL}
"
)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn version_line_is_name_then_version() {
assert_eq!(version_line(), format!("edamame {VERSION}"));
}
#[test]
fn help_lists_every_supported_flag() {
let help = help_text();
for flag in [
"-h",
"--help",
"-V",
"--version",
"--doctor",
"--diff",
"--no-config",
"--log",
] {
assert!(help.contains(flag), "--help omits {flag}");
}
assert!(help.contains(DOCS_URL));
assert!(help.contains(ISSUES_URL));
assert!(help.ends_with('\n'), "help text must end in a newline");
}
}