Remove structopt, add clap
This commit is contained in:
parent
8d7c446f4c
commit
d97d706c52
295
Cargo.lock
generated
295
Cargo.lock
generated
@ -21,14 +21,52 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.8"
|
||||
name = "anstream"
|
||||
version = "0.6.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af80143d6f7608d746df1520709e5d141c96f240b0e62b0aa41bdfb53374d9d4"
|
||||
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"termion",
|
||||
"winapi",
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -38,32 +76,69 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.0.1"
|
||||
name = "clap"
|
||||
version = "4.5.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf"
|
||||
checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.31.2"
|
||||
name = "clap_builder"
|
||||
version = "4.5.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0f16b89cbb9ee36d87483dc939fe9f1e13c05898d56d7b230a0d4dff033a536"
|
||||
checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"bitflags 1.0.1",
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
"textwrap",
|
||||
"unicode-width",
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2 1.0.91",
|
||||
"quote 1.0.37",
|
||||
"syn 2.0.89",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||
|
||||
[[package]]
|
||||
name = "getopts"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b900c08c1939860ce8b54dc6a89e26e00c04c380fd0e09796799bd7f12861e05"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.0.0"
|
||||
@ -100,13 +175,22 @@ dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.91"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "307e3004becf10f5a6e0d59d20f3cd28231b0e0827a96cd3e0ce6d14bc1e4bb3"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pulldown-cmark"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6fdf85cda6cadfae5428a54661d431330b312bc767ddbc57adbedc24da66e32"
|
||||
dependencies = [
|
||||
"bitflags 0.9.1",
|
||||
"bitflags",
|
||||
"getopts",
|
||||
]
|
||||
|
||||
@ -116,22 +200,16 @@ version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b0ff51282f28dc1b53fd154298feaa2e77c5ea0dba68e1fd8b03b72fbe13d2a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"proc-macro2 0.3.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.37"
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd"
|
||||
|
||||
[[package]]
|
||||
name = "redox_termios"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"redox_syscall",
|
||||
"proc-macro2 1.0.91",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -168,10 +246,10 @@ version = "1.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0477feff739386f5bca8e13fa43d96a4e834904d538f503906c8179f9205f50"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"proc-macro2 0.3.6",
|
||||
"quote 0.5.1",
|
||||
"serde_derive_internals",
|
||||
"syn",
|
||||
"syn 0.13.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -180,36 +258,15 @@ version = "0.23.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d30c4596450fd7bbda79ef15559683f9a79ac0193ea819db90000d7e1cae794"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
"proc-macro2 0.3.6",
|
||||
"syn 0.13.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.7.0"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
|
||||
|
||||
[[package]]
|
||||
name = "structopt"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1dbf9b178b64479997d9515aa4a6956ada20a9829fa03fee3bbcff5962e4e405"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"structopt-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "structopt-derive"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29040b33bfc5dae3a321f79cbcd86813a5f024e3040a31f057188e7f2b6228ba"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
@ -217,45 +274,36 @@ version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91b52877572087400e83d24b9178488541e3d535259e04ff17a63df1e5ceff59"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"proc-macro2 0.3.6",
|
||||
"quote 0.5.1",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.91",
|
||||
"quote 1.0.37",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "teascade-generator"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"clap",
|
||||
"pathdiff",
|
||||
"pulldown-cmark",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"structopt",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termion"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"redox_termios",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "0.3.5"
|
||||
@ -282,10 +330,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.4"
|
||||
name = "unicode-ident"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
|
||||
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
@ -309,10 +357,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.0"
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "void"
|
||||
@ -341,3 +389,76 @@ name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
@ -2,13 +2,15 @@
|
||||
name = "teascade-generator"
|
||||
version = "0.1.0"
|
||||
authors = ["Teascade <teascade@gmail.com>"]
|
||||
edition = "2021"
|
||||
|
||||
|
||||
[dependencies]
|
||||
pulldown-cmark = "*"
|
||||
toml = "*"
|
||||
structopt = "*"
|
||||
serde = "*"
|
||||
serde_derive = "*"
|
||||
regex = "*"
|
||||
ansi_term = "*"
|
||||
pathdiff = "*"
|
||||
clap = { version = "4.5.21", features = ["derive"] }
|
||||
|
@ -9,7 +9,7 @@ use crate::config::Config;
|
||||
use crate::error::Error;
|
||||
use crate::file_writer;
|
||||
use crate::logger::{LogLevel, Logger};
|
||||
use crate::options::{BuildOpt, Opt};
|
||||
use crate::options::Options;
|
||||
use crate::renderer;
|
||||
use crate::template::Template;
|
||||
|
||||
@ -28,7 +28,7 @@ fn fetch_config() -> Result<Config, Error> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build(logger: &Logger, opt: &Opt, _: &BuildOpt) -> Result<(), Error> {
|
||||
pub fn build(logger: &Logger, opt: &Options) -> Result<(), Error> {
|
||||
logger.log(LogLevel::INFO, "Starting build");
|
||||
let config = fetch_config()?;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
use std::path::PathBuf;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use crate::error::Error;
|
||||
use crate::file_writer;
|
||||
|
37
src/main.rs
37
src/main.rs
@ -1,34 +1,23 @@
|
||||
extern crate ansi_term;
|
||||
extern crate pathdiff;
|
||||
extern crate pulldown_cmark;
|
||||
extern crate regex;
|
||||
extern crate serde;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
#[macro_use]
|
||||
extern crate structopt;
|
||||
extern crate toml;
|
||||
|
||||
mod logger;
|
||||
mod options;
|
||||
mod error;
|
||||
mod config_toml;
|
||||
mod config;
|
||||
mod template;
|
||||
mod renderer;
|
||||
mod builder;
|
||||
mod new_page;
|
||||
mod config;
|
||||
mod config_toml;
|
||||
mod error;
|
||||
mod file_writer;
|
||||
mod logger;
|
||||
mod new_page;
|
||||
mod options;
|
||||
mod renderer;
|
||||
mod template;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::process::exit;
|
||||
|
||||
use structopt::StructOpt;
|
||||
use clap::Parser;
|
||||
|
||||
use crate::logger::{LogLevel, Logger};
|
||||
use crate::options::{Opt, Subcommands};
|
||||
use crate::config_toml::{GlobalConfigToml, NavbarConfig, NavbarItem, WebsiteConfig};
|
||||
use crate::logger::{LogLevel, Logger};
|
||||
use crate::options::{Options, Subcommands};
|
||||
|
||||
//TODO: Custom markdown
|
||||
fn main() {
|
||||
@ -39,13 +28,13 @@ fn main() {
|
||||
}
|
||||
|
||||
fn run() -> Result<(), ()> {
|
||||
let opt = Opt::from_args();
|
||||
let opt: Options = Options::parse();
|
||||
|
||||
let log_level = (3 - opt.quiet as i8 + opt.verbose as i8).max(0).min(5);
|
||||
let logger = Logger::new(LogLevel::from(log_level as u8));
|
||||
|
||||
match opt.clone().cmd {
|
||||
Subcommands::Build(build_opt) => match builder::build(&logger, &opt, &build_opt) {
|
||||
Subcommands::Build => match builder::build(&logger, &opt) {
|
||||
Ok(_) => {
|
||||
logger.log(LogLevel::DETAILER, "Building finished successfully.");
|
||||
Ok(())
|
||||
|
@ -4,7 +4,7 @@ use crate::config_toml::{GlobalConfigToml, PageConfig, PageConfigToml};
|
||||
use crate::error::Error;
|
||||
use crate::file_writer;
|
||||
use crate::logger::{LogLevel, Logger};
|
||||
use crate::options::{NewOpt, Opt};
|
||||
use crate::options::{NewOpt, Options};
|
||||
|
||||
use pathdiff;
|
||||
|
||||
@ -16,7 +16,7 @@ This is the markdown file, where you will insert this page's contents.
|
||||
|
||||
See [CommonMark](http://commonmark.org/help/) for reference."#;
|
||||
|
||||
pub fn generate_new_page(logger: &Logger, opt: &Opt, new_opt: &NewOpt) -> Result<(), Error> {
|
||||
pub fn generate_new_page(logger: &Logger, opt: &Options, new_opt: &NewOpt) -> Result<(), Error> {
|
||||
logger.log(
|
||||
LogLevel::DETAILER,
|
||||
format!("Starting to create paths for given files"),
|
||||
|
@ -1,79 +1,82 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(StructOpt, Debug, Clone)]
|
||||
#[structopt(name = "Teasca.de Generator",
|
||||
about = "A website generator, used mainly for generating teasca.de")]
|
||||
pub struct Opt {
|
||||
/// Verbose flag, makes the program more noisy. (-vv for maximum noisiness)
|
||||
#[structopt(short = "v", long = "verbose", parse(from_occurrences))]
|
||||
pub verbose: u8,
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
/// Quiet flag, makes the program less noisy. (-qqq for minimum noisiness)
|
||||
#[structopt(short = "q", long = "quiet", parse(from_occurrences))]
|
||||
// #[structopt(name = "Teasca.de Generator",
|
||||
// about = "A website generator, used mainly for generating teasca.de")]
|
||||
/// Hello!
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct Options {
|
||||
/// verbose flag, makes the program more noisy. (-vv for maximum noisiness)
|
||||
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||
pub verbose: u8,
|
||||
/// quiet flag, makes the program less noisy. (-qqq for minimum noisiness)
|
||||
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||
pub quiet: u8,
|
||||
|
||||
/// Overwrites necessary files to create new ones.
|
||||
#[structopt(short = "o", long = "overwrite")]
|
||||
/// overwrites necessary files to create new ones.
|
||||
#[arg(short, long)]
|
||||
pub overwrite: bool,
|
||||
|
||||
#[structopt(subcommand)]
|
||||
#[command(subcommand)]
|
||||
pub cmd: Subcommands,
|
||||
}
|
||||
|
||||
#[derive(StructOpt, Debug, Clone)]
|
||||
#[derive(Subcommand, Debug, Clone)]
|
||||
pub enum Subcommands {
|
||||
/// Build the website
|
||||
#[structopt(name = "build")]
|
||||
Build(BuildOpt),
|
||||
Build,
|
||||
/// Create a new page
|
||||
#[structopt(name = "new")]
|
||||
New(NewOpt),
|
||||
/// Initializes a config.toml
|
||||
#[structopt(name = "init")]
|
||||
#[command(name = "init")]
|
||||
Initialize(InitializeOpt),
|
||||
}
|
||||
|
||||
#[derive(StructOpt, Debug, Clone)]
|
||||
pub struct BuildOpt {}
|
||||
|
||||
#[derive(StructOpt, Debug, Clone)]
|
||||
/// beep
|
||||
// #[argh(subcommand, name = "new")]
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
#[clap(disable_help_flag = true)]
|
||||
pub struct NewOpt {
|
||||
/// File path for the .toml file created
|
||||
#[structopt(parse(from_os_str))]
|
||||
#[clap(long, action = clap::ArgAction::HelpLong)]
|
||||
help: Option<bool>,
|
||||
|
||||
/// file path for the .toml file created
|
||||
pub toml_path: PathBuf,
|
||||
|
||||
/// File path for the markdown file created
|
||||
#[structopt(short = "m", long = "markdown", parse(from_os_str))]
|
||||
pub markdown_path: Option<PathBuf>,
|
||||
/// file path for the markdown file created
|
||||
#[arg(long = "markdown", short)]
|
||||
pub markdown_path: Option<PathBuf>, // TODO, should be 'markdown'
|
||||
|
||||
/// Outpuh html file path of the generated page
|
||||
#[structopt(short = "h", long = "html", parse(from_os_str))]
|
||||
pub html_path: Option<PathBuf>,
|
||||
/// output html file path of the generated page
|
||||
#[arg(long = "html", short)]
|
||||
pub html_path: Option<PathBuf>, // TODO, should be 'html'
|
||||
|
||||
/// Sets the title of the generated page
|
||||
#[structopt(short = "t", long = "title")]
|
||||
/// sets the title of the generated page
|
||||
#[arg(short, long)]
|
||||
pub title: Option<String>,
|
||||
|
||||
/// Don't modify config.toml automatically
|
||||
#[structopt(short = "n", long = "no-modify-config")]
|
||||
/// don't modify config.toml automatically
|
||||
#[arg(short, long)]
|
||||
pub no_modify_config: bool,
|
||||
}
|
||||
|
||||
#[derive(StructOpt, Debug, Clone)]
|
||||
/// beep
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
pub struct InitializeOpt {
|
||||
/// Name of the webpage
|
||||
#[structopt()]
|
||||
/// name of the webpage
|
||||
pub name: String,
|
||||
|
||||
/// Favicon
|
||||
#[structopt(short = "f", long = "favicon")]
|
||||
/// favicon
|
||||
#[arg(short, long)]
|
||||
pub favicon: Option<String>,
|
||||
|
||||
/// Twitter author
|
||||
#[structopt(short = "t", long = "twitter")]
|
||||
/// twitter author
|
||||
#[arg(long = "twitter", short)]
|
||||
pub twitter_author: Option<String>,
|
||||
|
||||
/// Disables the default navbar
|
||||
#[structopt(short = "n", long = "no-navbar")]
|
||||
/// disables the default navbar
|
||||
#[arg(short, long = "no-navbar")]
|
||||
pub no_default_navbar: bool,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user