diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-09-05 14:46:49 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-09-05 14:46:49 +0100 |
commit | 38cfe0b12b45d703375682cce5b45fbbbe2fce07 (patch) | |
tree | a3395f0cdcd371123f2f4472a230d7337cc21534 /src | |
parent | 52293448680bbbd81c78bc7b6c1350d034d6b660 (diff) | |
download | subplot-38cfe0b12b45d703375682cce5b45fbbbe2fce07.tar.gz |
resources: Hidden subcommand to list internal resources
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/subplot.rs | 19 | ||||
-rw-r--r-- | src/resource.rs | 5 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/bin/subplot.rs b/src/bin/subplot.rs index d4685da..b8524e1 100644 --- a/src/bin/subplot.rs +++ b/src/bin/subplot.rs @@ -55,6 +55,7 @@ enum Cmd { Metadata(Metadata), Docgen(Docgen), Codegen(Codegen), + Resources(Resources), } impl Cmd { @@ -65,6 +66,7 @@ impl Cmd { Cmd::Metadata(m) => m.run(), Cmd::Docgen(d) => d.run(), Cmd::Codegen(c) => c.run(), + Cmd::Resources(r) => r.run(), } } @@ -75,6 +77,7 @@ impl Cmd { Cmd::Metadata(m) => m.doc_path(), Cmd::Docgen(d) => d.doc_path(), Cmd::Codegen(c) => c.doc_path(), + Cmd::Resources(r) => r.doc_path(), } } } @@ -107,6 +110,22 @@ fn long_version() -> Result<String> { } #[derive(Debug, StructOpt)] +/// Examine embedded resources built into Subplot +#[structopt(setting = structopt::clap::AppSettings::Hidden)] +struct Resources {} + +impl Resources { + fn doc_path(&self) -> Option<&Path> { + None + } + fn run(&self) -> Result<()> { + for (name, bytes) in subplot::resource::embedded_files() { + println!("{} {} bytes", name, bytes.len()); + } + Ok(()) + } +} +#[derive(Debug, StructOpt)] /// Extract embedded files from a subplot document /// /// If no embedded filenames are provided, this will diff --git a/src/resource.rs b/src/resource.rs index f22e1ef..cfcc63a 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -50,6 +50,11 @@ lazy_static! { static EMBEDDED_FILES: &[(&str, &[u8])] = include!(concat!(env!("OUT_DIR"), "/embedded_files.inc")); +/// Retrieve the embedded file list +pub fn embedded_files() -> &'static [(&'static str, &'static [u8])] { + EMBEDDED_FILES +} + /// Put a path at the back of the queue to search in fn add_search_path<P: AsRef<Path>>(path: P) { SEARCH_PATHS |