feat(random): flag --random to open browser on random note
This commit is contained in:
parent
e3dc697e42
commit
1bf0eec41f
@ -41,6 +41,6 @@ repos:
|
||||
- id: check-todos # [NOGREP]
|
||||
name: check-todos # [NOGREP]
|
||||
language: system
|
||||
entry: sh -c "! grep --color=always --binary-files=without-match --dereference-recursive --exclude-dir='notes' --exclude-dir='node_modules' --exclude-dir='.git' --exclude='.pre-commit-config.yaml' --exclude-dir='venv' 'TODO'" # [NOGREP]
|
||||
entry: sh -c "! grep --color=always --binary-files=without-match --dereference-recursive --exclude-dir='notes' --exclude-dir='target' --exclude-dir='node_modules' --exclude-dir='.git' --exclude='.pre-commit-config.yaml' --exclude-dir='venv' 'TODO'" # [NOGREP]
|
||||
pass_filenames: false
|
||||
always_run: true
|
||||
|
||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -982,7 +982,7 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
|
||||
|
||||
[[package]]
|
||||
name = "mdpreview"
|
||||
version = "0.2.1"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"askama",
|
||||
"askama_axum",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mdpreview"
|
||||
version = "0.2.1"
|
||||
version = "0.3.0"
|
||||
edition = "2024"
|
||||
authors = ["Vladislav Kan <thek4n@yandex.ru>"]
|
||||
|
||||
|
||||
15
src/main.rs
15
src/main.rs
@ -61,15 +61,23 @@ pub struct NoteTemplate {
|
||||
#[derive(clap::Parser, Debug)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
/// Host to listen
|
||||
#[arg(long, default_value_t = String::from("localhost"))]
|
||||
host: String,
|
||||
|
||||
/// Port to listen
|
||||
#[arg(short, long, default_value_t = 8080)]
|
||||
port: u16,
|
||||
|
||||
#[arg(long)]
|
||||
/// Open browser
|
||||
#[arg(long, default_value_t = false)]
|
||||
browser: bool,
|
||||
|
||||
/// Open browser on random note. Requires flag --broswer
|
||||
#[arg(long, default_value_t = false, requires = "browser")]
|
||||
random: bool,
|
||||
|
||||
/// Notes root
|
||||
#[arg()]
|
||||
root: PathBuf,
|
||||
}
|
||||
@ -131,7 +139,10 @@ async fn main() {
|
||||
println!("Server started on http://{actual_addr}");
|
||||
|
||||
if args.browser {
|
||||
let url = format!("http://{actual_addr}");
|
||||
let mut url = format!("http://{actual_addr}");
|
||||
if args.random {
|
||||
url = format!("{url}/random")
|
||||
}
|
||||
let _ = webbrowser::open(url.as_str());
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user