Skip to content

Commit

Permalink
Add doc link to help modal and CLI help
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasPickering committed Jan 2, 2025
1 parent e000b45 commit 1f5c96f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const COMMAND_NAME: &str = "slumber";
/// Configurable HTTP client with both TUI and CLI interfaces
///
/// If subcommand is omitted, start the TUI.
///
/// https://slumber.lucaspickering.me/book/
#[derive(Debug, Parser)]
#[clap(author, version, about, name = COMMAND_NAME)]
pub struct Args {
Expand Down
8 changes: 6 additions & 2 deletions crates/core/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use std::{
use tokio::sync::{Mutex, OwnedRwLockWriteGuard, RwLock};
use tracing::error;

const WEBSITE: &str = "https://slumber.lucaspickering.me";
/// Link to the GitHub New Issue form
pub const NEW_ISSUE_LINK: &str =
"https://github.com/LucasPickering/slumber/issues/new/choose";
Expand All @@ -36,7 +35,12 @@ pub const NEW_ISSUE_LINK: &str =
/// );
/// ```
pub fn doc_link(path: &str) -> String {
format!("{WEBSITE}/book/{path}.html")
const ROOT: &str = "https://slumber.lucaspickering.me/book/";
if path.is_empty() {
ROOT.into()
} else {
format!("{ROOT}{path}.html")
}
}

/// Parse bytes from a reader into YAML. This will merge any anchors/aliases.
Expand Down
5 changes: 3 additions & 2 deletions crates/tui/src/view/component/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use ratatui::{
Frame,
};
use slumber_config::{Action, Config, InputBinding};
use slumber_core::util::paths;
use slumber_core::util::{doc_link, paths};

const CRATE_VERSION: &str = env!("CARGO_PKG_VERSION");

Expand Down Expand Up @@ -53,7 +53,7 @@ pub struct HelpModal;

impl HelpModal {
/// Number of lines in the general section (not including header)
const GENERAL_LENGTH: u16 = 4;
const GENERAL_LENGTH: u16 = 5;

/// Get the list of bindings that will be shown in the modal
fn bindings() -> impl Iterator<Item = (Action, &'static InputBinding)> {
Expand Down Expand Up @@ -97,6 +97,7 @@ impl Draw for HelpModal {
title: Some("General"),
rows: [
("Version", Line::from(CRATE_VERSION)),
("Docs", doc_link("").into()),
("Configuration", Config::path().display().to_string().into()),
("Log", paths::log_file().display().to_string().into()),
(
Expand Down

0 comments on commit 1f5c96f

Please sign in to comment.