Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 16 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ authors = ["Samuel Åkesson <sermuns@lysator.liu.se>"]
askama = { version = "0.15", default-features = false, features = ["std", "derive"] }
axum = { version = "0.8", default-features = false, features = ["tokio", "http1"] }
clap = { version = "4", features = ["derive"] }
clap_mangen = "0.3"
color-eyre = { version = "0.6", default-features = false, features = ["track-caller"] }
comrak = { version = "0.52", default-features = false, features = ["bon", "shortcodes", "syntect"] }
futures = { version = "0.3", default-features = false }
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ Options:
-a, --address <ADDRESS> Address to bind the server to [default: localhost:3000]
-o, --open Whether to open the browser on serve
-l, --light-mode Render page in light-mode style
--generate-manpage Print manpage to stdout and exit
-h, --help Print help
-V, --version Print version
```
Expand Down Expand Up @@ -138,6 +137,10 @@ Can be installed by

```bash
mkdir -p ~/.local/share/man/man1/
meread --generate-manpage > ~/.local/share/man/man1/meread.1
```
# if downloaded from source using `git clone`:
cp ./meread.1 ~/.local/share/man/man1/meread.1

# otherwise:
curl -fsSL -o ~/.local/share/man/man1/meread.1 \
"https://raw.githubusercontent.com/sermuns/MEREAD/main/meread.1"
```
50 changes: 50 additions & 0 deletions meread.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.TH MEREAD 1 ""
.SH NAME
\fBmeread\fR \- preview github flavored markdown locally
.
.SH SYNOPSIS
.B meread
.RB [ \-e | \-\-export\-dir
.IR directory ]
.RB [ \-f | \-\-force ]
.RB [ \-a | \-\-address
.IR address ]
.RB [ \-o | \-\-open ]
.RB [ \-l | \-\-light\-mode ]
.RB [ \-h | \-\-help ]
.RB [ \-V | \-\-version ]
.RI [ path ]
.
.SH DESCRIPTION
\fBmeread\fR is a command\-line tool for previewing Markdown files as they
will be presented on GitHub, all completely locally and offline.
.
.SH OPTIONS
.TP
.I path
Path to markdown file or directory containing README.md [default: \fB.\fR].
.TP
.BR \-e ", " \-\-export\-dir " \fIdirectory\fR"
If supplied, will export the markdown file to HTML in the specified directory.
.TP
.BR \-f ", " \-\-force
Whether to overwrite the export directory if it exists.
.TP
.BR \-a ", " \-\-address " \fIaddress\fR"
The address to bind the server to [default: \fBlocalhost:3000\fR].
.TP
.BR \-o ", " \-\-open
Whether to open the browser on serve.
.TP
.BR \-l ", " \-\-light\-mode
Render page in light\-mode style.
.TP
.BR \-h ", " \-\-help
Print help.
.TP
.BR \-V ", " \-\-version
Print version.
.
.SH BUGS
Bugs can be reported on GitHub:
.I https://github.com/sermuns/MEREAD/issues
7 changes: 7 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ in

src = ./.;

# for installManPage
nativeBuildInputs = [pkgs.installShellFiles];

postInstall = ''
installManPage ./meread.1
'';

meta = {
inherit (toml) description license;
homepage = toml.repository;
Expand Down
12 changes: 1 addition & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use axum::{
response::{Html, IntoResponse},
routing::get,
};
use clap::{CommandFactory, Parser};
use clap::Parser;
use color_eyre::{
Result,
eyre::{Context, ContextCompat},
Expand Down Expand Up @@ -59,10 +59,6 @@ struct Args {
/// Render page in light-mode style
#[arg(long, short)]
light_mode: bool,

/// Print manpage to stdout and exit
#[arg(long)]
generate_manpage: bool,
}

#[tokio::main(flavor = "current_thread")]
Expand All @@ -74,12 +70,6 @@ async fn main() -> Result<()> {

let args = Args::parse();

if args.generate_manpage {
let cmd = Args::command();
clap_mangen::Man::new(cmd).render(&mut std::io::stdout())?;
return Ok(());
}

let markdown_file_path = if args.path.is_dir() {
args.path.join("README.md")
} else {
Expand Down