Skip to content

Commit

Permalink
Added CLI options for all new config parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
shombando committed Apr 18, 2024
1 parent 2c9ff25 commit d091644
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This is a tool for anyone who has some kind of personal website or blog and wish
- Highly optimized
- Auto-detect webring links on sites
- Fully customizable via templates
- Generates a [OPML](https://opml.org/) file with all sites that have a RSS feed
- Choice of command-line interface or config file
- Remote config file support too
- Shuffle option
Expand Down Expand Up @@ -57,7 +58,12 @@ Command-line arguments take precedence over any settings in the config file.
- *`-o`, `--output`*: Define the output folder, where the generated files will be saved. Default: `./webring`
- *`-a`, `--assets`*: Specify the assets folder. Any files in here will be copied to the output folder. This lets you include any extra files you want, such as images or extra web pages, etc. Default: `./data/assets`
- *`-t`, `--templates`*: Specify path to the template folder. Use `template.html` for redirect pages (i.e. the HTML which composes the webring). Any extra pages can be added here if you want them to be populated with generated content. Default: `./data/templates`
- *`--skip-minification`*: Outputs pages without optimizing or modifying them. Try this if you want your generated files to be hand-editable later, or if you experience any unexpected issues with the output.
- *`-u`, `--url`*: The base URL for the webring. Something like 'https://example.com'.
- *`-n`, `--name`*: The name of the webring. Something like 'Ghostring'.
- *`-d`, `--description`*: A short description/about the webring.
- *`-m`, `--maintainer`*: The owner/maintainer of the webring, could be a person or an organization.
- *`-w`, `--website`*: The website link of the website owner, not the base URL of the webring.
- *`--skip-minification`*: Outputs pages without optimizing or modifying them. Try this if you want your generated files to be hand-editable later, or if you experience any unexpected issues with the output.
- *`--skip-verification`*: Generates files without checking for potential problems...unwise!
- *`--dry-run`*: Runs the application without outputting any files
- *`-s`, `--shuffle`*: Randomly shuffles the order of websites during generation. This is totally internal and does not affect the input list of websites; you can shuffle the same webring repeatedly without losing the original sequence.
Expand Down Expand Up @@ -94,6 +100,7 @@ The following tags are currently usable in templates:
- *`{{ table_of_sites }}`* produces a formatted HTML table listing information for all sites in the webring.
- *`{{ number_of_sites }}`* shows the current size of the webring.
- *`{{ current_time }}`* displays the time of generating, showing when the page was last updated.
- *`{{ opml }}`* inserts the relative path of the ring's OPML file.

Right now, `{{ url }}` is a special tag that only works in `template.html` for the next/previous links.

Expand Down
44 changes: 44 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,38 @@ pub struct ClapSettings {
)]
pub base_url: Option<String>,

#[clap(
short = 'n',
long = "name",
ignore_case = false,
help = "The name of the webring. Something like 'Ghostring'."
)]
pub ring_name: Option<String>,

#[clap(
short = 'd',
long = "description",
ignore_case = false,
help = "A short description/about the webring."
)]
pub ring_description: Option<String>,

#[clap(
short = 'm',
long = "maintainer",
ignore_case = false,
help = "The owner/maintainer of the webring, could be a person or an organization."
)]
pub ring_owner: Option<String>,

#[clap(
short = 'w',
long = "website",
ignore_case = false,
help = "The website link of the website owner, not the base URL of the webring."
)]
pub ring_owner_site: Option<String>,

#[clap(short = 'A', long = "audit", action = ArgAction::SetTrue, help = "Scrapes URLs to check for the webring links before adding them to the list. If the links can't be found, the site will get skipped. ")]
pub audit: bool,

Expand Down Expand Up @@ -201,6 +233,18 @@ fn merge_configs(cli_args: ClapSettings, config: Option<ConfigSettings>) -> AppS
}

// Then, override with CLI arguments if provided
if let Some(val) = cli_args.ring_name {
final_settings.ring_name = val;
}
if let Some(val) = cli_args.ring_description {
final_settings.ring_description = val;
}
if let Some(val) = cli_args.ring_owner {
final_settings.ring_owner = val;
}
if let Some(val) = cli_args.ring_owner_site {
final_settings.ring_owner_site = val;
}
if let Some(val) = cli_args.filepath_list {
final_settings.filepath_list = val;
}
Expand Down

0 comments on commit d091644

Please sign in to comment.