diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-01-09 16:15:35 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2021-01-10 09:49:25 +0000 |
commit | fcdbd77cc2b909b8a1d0fc8d2e6343bbc278470c (patch) | |
tree | 05420ead169a05ae3a2b0a7c4564e230596f1fb0 /src/resource.rs | |
parent | e9b941e5218e5e4293bb915b13f831baba246a89 (diff) | |
download | subplot-fcdbd77cc2b909b8a1d0fc8d2e6343bbc278470c.tar.gz |
resource: Switch from 'templates' to 'share'
In a general sense, we will want to have more than just template
files as resources. This shifts from the concept that the only
thing resource-wise that subplot has is templates, to a more general
shared resources concept without a default path beyond CWD.
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'src/resource.rs')
-rw-r--r-- | src/resource.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/resource.rs b/src/resource.rs index dd30678..48c8cc5 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -8,6 +8,30 @@ use std::io::{self, Read}; use std::path::{Path, PathBuf}; use std::sync::Mutex; +use structopt::StructOpt; + +#[derive(Debug, StructOpt)] +/// Options which relate to resource management +/// +/// To use this, include them *flat* in your options struct, and then after +/// parsing, call the [ResourceOpts::handle()] function. +pub struct ResourceOpts { + #[structopt( + long, + help = "Look for code templates and other resources in DIR", + name = "DIR" + )] + resources: Option<PathBuf>, +} + +impl ResourceOpts { + /// Handle any supplied resource related arguments + pub fn handle(&self) { + if let Some(rpath) = self.resources.as_ref() { + add_search_path(rpath); + } + } +} use lazy_static::lazy_static; |