Skip to content

Commit

Permalink
v0.8.5 - New command line argument --match-files that acts as a filte…
Browse files Browse the repository at this point in the history
…r for the configuration files present for the project
  • Loading branch information
TheRustifyer committed Apr 5, 2023
1 parent b4dda38 commit b0c1a52
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 13 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- make the project model full owned, and cache it?
- generate a second `std.h` to bind to the Zork++ autogenerated `modulemap` when `libc++`
is selected as the target standard library
-

## [0.8.5] - 2023 - 04 - 05

### Feature

- Added a command line argument named `--match-files` that filters all the detected configuration
files for the project by checking if the value of the argument is a substring of the filename of
every config file.


## [0.8.4] - 2023 - 04 - 02

### Fix
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,13 @@ a minimal setup. This command includes some arguments to make it more flexible,
- `--compiler <COMPILER>` ⇒ indicates which of the compilers available within `Zork++`
should be used to set up the template

- `-v` ⇒ Outputs more information to stdout. The classical `verbose` command line flag
#### Arguments (they should be place before the main subcommands described above)

- `--match-files` => Accepts an string value that will be used to perform a filter to the detected `Zork++`
configuration files present in the project. Acts like the classical `contains` method, by checking that the value
that you passed in is a substring of some of the detected config files.
- `-v` ⇒ Outputs more information to stdout. The classical `verbose` command line flag. You have until
`-vv`, which is the maximum verbosity allowed, that will unlock the trace level logs.
- `-c,`--clear-cache` ⇒ Clears the files in the cache, so, in the next iteration, cached items
must be processed again. This is useful after a lot of program iterations, when the cache starts
to slow down the build process.
Expand Down
2 changes: 1 addition & 1 deletion release-config/windows-installer-zork.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Zork++"
#define MyAppVersion "0.8.4"
#define MyAppVersion "0.8.5"
#define MyAppPublisher "Zero Day Code"
#define MyAppURL "https://github.com/zerodaycode/Zork"
#define MyAppExeName "zork++.exe"
Expand Down
2 changes: 1 addition & 1 deletion zork++/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions zork++/src/lib/cli/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,26 @@ use clap::{Parser, Subcommand, ValueEnum};
/// use clap::Parser;
/// use zork::cli::input::{CliArgs, Command, CppCompiler};
///
/// let parser = CliArgs::parse_from(["", "-vv", "--clear-cache", "test"]);
/// let parser = CliArgs::parse_from(
/// ["", "-vv", "--match-files", "zork_linux.toml", "--clear-cache", "test"]
/// );
/// assert_eq!(parser.command, Command::Test);
/// assert_eq!(parser.verbose, 2);
/// assert_eq!(parser.clear_cache, true);
/// assert_eq!(parser.match_files, Some(String::from("zork_linux.toml")));
///
// Create Template Project
/// let parser = CliArgs::parse_from(["", "new", "example", "--git", "--compiler", "clang"]);
/// assert_eq!(parser.command, Command::New{name: "example".to_owned(), git: true, compiler: CppCompiler::CLANG, template: "basic".to_owned()});
///
// Run autogenerated project
/// let parser = CliArgs::parse_from(["", "-vv", "run"]);
/// assert_eq!(parser.command, Command::Run);
// let parser = CliArgs::parse_from(["", "-vv", "run"]);
// assert_eq!(parser.command, Command::Run);
/// ```
#[derive(Parser, Debug, Default)]
#[command(name = "Zork++")]
#[command(author = "Zero Day Code")]
#[command(version = "0.8.3")]
#[command(version = "0.8.5")]
#[command(
about = "Zork++ is a build system for modern C++ projects",
long_about = "Zork++ is a project of Zero Day Code. Find us: https://github.com/zerodaycode/Zork"
Expand All @@ -38,6 +41,9 @@ pub struct CliArgs {

#[arg(short, long, help = "Removes all the entries stored in the cache")]
pub clear_cache: bool,

#[arg(short, long, help = "Filters between the Zork++ configuration files for the project, taking only the ones that contains in their name the value passed in")]
pub match_files: Option<String>,
}

/// [`Command`] - The core enum commands
Expand All @@ -46,7 +52,7 @@ pub enum Command {
/// Triggers the process that builds the project based on the config file directives
#[default]
Build,
/// Performns a
/// Builds and runs the targetted project
Run,
/// Executes the tests under the specified directory in the config file
Test,
Expand Down
2 changes: 1 addition & 1 deletion zork++/src/lib/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub mod worker {
return create_templated_project(path, name, git, compiler.into(), template);
};

let config_files: Vec<ConfigFile> = find_config_files(path)
let config_files: Vec<ConfigFile> = find_config_files(path, &cli_args.match_files)
.with_context(|| "We didn't found a valid Zork++ configuration file")?;
log::trace!("Config files found: {config_files:?}");

Expand Down
9 changes: 6 additions & 3 deletions zork++/src/lib/utils/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct ConfigFile {
///
/// This function fails if there's no configuration file
/// (or isn't present in any directory of the project)
pub fn find_config_files(base_path: &Path) -> Result<Vec<ConfigFile>> {
pub fn find_config_files(base_path: &Path, filename_match: &Option<String>) -> Result<Vec<ConfigFile>> {
log::debug!("Searching for Zork++ configuration files...");
let mut files = vec![];

Expand All @@ -60,9 +60,12 @@ pub fn find_config_files(base_path: &Path) -> Result<Vec<ConfigFile>> {
.into_iter()
.filter_map(|e| e.ok())
{
let filename = e.file_name().to_str().unwrap();
let file_match = filename_match.as_ref().map(|fm| fm.as_str()).unwrap_or(filename);
if e.metadata().unwrap().is_file()
&& e.file_name().to_str().unwrap().starts_with("zork")
&& e.file_name().to_str().unwrap().ends_with(".toml")
&& filename.starts_with("zork")
&& filename.ends_with(".toml")
&& filename.contains(&file_match)
{
files.push(ConfigFile {
dir_entry: e.clone(),
Expand Down

0 comments on commit b0c1a52

Please sign in to comment.