pub struct Cli;Expand description
A simple CLI struct for building the SSG command.
Implementations§
Source§impl Cli
impl Cli
Sourcepub fn build() -> Command
pub fn build() -> Command
Builds the legacy flag-style clap::Command.
Preserved so the deprecation shim, existing examples, and the already-shipped CI invocations keep working through the 0.0.x line. Removed in 1.0 per issue #527 AC7.
§Examples
use ssg::cmd::Cli;
let cmd = Cli::build();
assert!(cmd.get_name().contains("ssg") || !cmd.get_name().is_empty());Sourcepub fn subcommand_app() -> Command
pub fn subcommand_app() -> Command
Builds the subcommand-style clap::Command (issue #527).
Surface:
ssg <SUBCOMMAND> [OPTIONS]
Development:
dev Start the dev server with file watching
Build:
build Produce a static site under the configured output dir
Validate:
check Run validators (read-only) and exit
Deploy:
deploy Build and ship to a pluggable targetEach subcommand carries the same --config / --output / …
option pile so existing scripts can be ported one-to-one.
§Examples
use ssg::cmd::Cli;
let app = Cli::subcommand_app();
let names: Vec<_> = app.get_subcommands().map(|c| c.get_name()).collect();
assert!(names.contains(&"build"));
assert!(names.contains(&"dev"));Sourcepub fn parse_and_dispatch<I, T>(
argv: I,
) -> Result<(CliInvocation, ArgMatches), Error>
pub fn parse_and_dispatch<I, T>( argv: I, ) -> Result<(CliInvocation, ArgMatches), Error>
Routes argv to either the subcommand parser or the legacy
flag parser.
The contract:
- If
argv[1]matches a known subcommand (build,dev,check,deploy,help), parses with the new surface. - Otherwise, falls back to the legacy parser and prints
LEGACY_DEPRECATION_WARNINGto stderr (issue #527 AC5, except when no args were supplied at all — baressgis silent and behaves like the prior 0.0.42 default).
Returns a (CliInvocation, ArgMatches) pair so the caller can
reuse the existing SsgConfig::from_matches / RunOptions::from_matches
helpers.
§Examples
use ssg::cmd::{Cli, CliInvocation};
let (inv, _matches) = Cli::parse_and_dispatch(vec!["ssg", "build"])
.expect("parses");
assert!(matches!(inv, CliInvocation::Build));§Errors
Returns the underlying clap::Error if parsing fails — the
caller is expected to print it and exit non-zero.
Displays the application banner
§Examples
use ssg::cmd::Cli;
// Prints to stdout — runnable in a doctest, no panics.
Cli::print_banner();Trait Implementations§
Auto Trait Implementations§
impl Freeze for Cli
impl RefUnwindSafe for Cli
impl Send for Cli
impl Sync for Cli
impl Unpin for Cli
impl UnsafeUnpin for Cli
impl UnwindSafe for Cli
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more