-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
finish build new template project #54
finish build new template project #54
Conversation
zork++/src/lib/utils/template.rs
Outdated
) { | ||
// TODO required validate or control optionals | ||
info!("Create template project"); | ||
let name = name_template.as_deref().unwrap_or("calculator"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review the lines 29-32. There's no need to dereference the option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its solved
zork++/src/lib/utils/template.rs
Outdated
// TODO required validate or control optionals | ||
info!("Create template project"); | ||
let name = name_template.as_deref().unwrap_or("calculator"); | ||
let resolved_compiler = compiler.clone().unwrap_or(CppCompiler::CLANG); // Deref ??? and not clone? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to clone. Also, there's no need to pass the Optionals there as references. Move the values (ie, pass by value)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is solved we required CppCompiler use Clone because ValueEnum hasnt implementarios Copy trait
zork++/src/lib/utils/template.rs
Outdated
zork_conf = zork_conf.replace("libcpp", "stdlib") | ||
} | ||
create_file( | ||
&PathBuf::from_str(root_path.to_str().unwrap()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace raw .unwrap()
for .expect(msg)
, or better use if let
pattern in these situations
zork++/src/lib/utils/template.rs
Outdated
} | ||
"; | ||
|
||
const SRC_MOD_FILE_2: &'static str = " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MOVE all the str slices to it's own file, ie: constants.rs or simillar
zork++/src/lib/utils/template.rs
Outdated
" | ||
.as_bytes(); | ||
|
||
const SRC_MOD_FILE: &'static str = " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's usually a code smell anotate the lifetime of const
or static
string slices. They are always static
, as they are stored directly in the generated binary. Remove the 'static
lifetimes of those const
declarations
zork++/src/lib/utils/template.rs
Outdated
DirBuilder::new() | ||
.recursive(true) | ||
.create(path_create) | ||
.expect(format!("Error create directory: {}", path_create.to_string_lossy()).as_str()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error create directory
=> `Error create directory
zork++/src/lib/utils/template.rs
Outdated
DirBuilder::new() | ||
.recursive(true) | ||
.create(path_create) | ||
.expect(format!("Error create directory: {}", path_create.to_string_lossy()).as_str()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.to_string_lossy()
. Try to use one of the UTF-8
alternatives to mantain consistency across the whole API
zork++/src/bin/main.rs
Outdated
@@ -10,4 +16,19 @@ fn main() { | |||
log::warn!("warn"); | |||
log::info!("info"); | |||
log::error!("error"); | |||
|
|||
create_template_project(&Some("proyect".to_owned()), true, &Some(CppCompiler::CLANG)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are passing default useless values. Remove then from the call site (here) or explictly pass a valid reference to the parser_cli
args
move to constant variables
6b3822f
to
7aed694
Compare
…. Cleaned up code smells
zork++/src/bin/main.rs
Outdated
match parser_cli.command.unwrap() { | ||
zork::config_cli::Command::Tests => todo!(), | ||
} | ||
}else{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New code hasn't been formated, as usual...
zork++/src/bin/main.rs
Outdated
|
||
} | ||
|
||
fn execution_procces(path: &Path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn execution_process()
isn't documented. Probably we may know what the function is doing, but not other people involved in the project. Every new feature in the code must be documented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheHiddenOnSystem solve the TODO's letfted on the code and request for approve again
04a95a2
into
zerodaycode:feature/GH-45-rewrite-zork++-from-scratch-in-rust
No description provided.