0.2.1: bug fix overwrite mode
This commit is contained in:
parent
e4780cf729
commit
5c098cfc98
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -4,7 +4,7 @@ version = 4
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bin2hpp"
|
name = "bin2hpp"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "bin2hpp"
|
name = "bin2hpp"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
authors = ["Adam Macdonald"]
|
authors = ["Adam Macdonald"]
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
|
@ -69,7 +69,7 @@ pub fn parse_config_from_args(args: &CliArgs) -> Result<Config, ProgramConfigErr
|
|||||||
constness: args.constness,
|
constness: args.constness,
|
||||||
symbol_name: match &args.symbol_name {
|
symbol_name: match &args.symbol_name {
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
if s.chars().all(|c| c.is_ascii_alphanumeric()) {
|
if s.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') {
|
||||||
s.to_string()
|
s.to_string()
|
||||||
} else {
|
} else {
|
||||||
return Err(ProgramConfigError::InvalidSymbolName(s.to_string()));
|
return Err(ProgramConfigError::InvalidSymbolName(s.to_string()));
|
||||||
@ -101,7 +101,7 @@ pub fn parse_config_from_args(args: &CliArgs) -> Result<Config, ProgramConfigErr
|
|||||||
},
|
},
|
||||||
namespace: match &args.namespace {
|
namespace: match &args.namespace {
|
||||||
Some(ns) => {
|
Some(ns) => {
|
||||||
if ns.chars().all(|c| c.is_ascii_alphanumeric()) {
|
if ns.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') {
|
||||||
Some(ns.to_string())
|
Some(ns.to_string())
|
||||||
} else {
|
} else {
|
||||||
return Err(ProgramConfigError::InvalidSymbolName(ns.to_string()));
|
return Err(ProgramConfigError::InvalidSymbolName(ns.to_string()));
|
||||||
@ -111,7 +111,7 @@ pub fn parse_config_from_args(args: &CliArgs) -> Result<Config, ProgramConfigErr
|
|||||||
},
|
},
|
||||||
guard_name: match &args.guard_name {
|
guard_name: match &args.guard_name {
|
||||||
Some(guard) => {
|
Some(guard) => {
|
||||||
if guard.chars().all(|c| c.is_ascii_alphanumeric()) {
|
if guard.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') {
|
||||||
guard.clone()
|
guard.clone()
|
||||||
} else {
|
} else {
|
||||||
return Err(ProgramConfigError::InvalidSymbolName(guard.to_string()));
|
return Err(ProgramConfigError::InvalidSymbolName(guard.to_string()));
|
||||||
|
@ -21,9 +21,11 @@ OUTPUT OPTIONS:
|
|||||||
|
|
||||||
--lf Use UNIX-style LF line endings (default)
|
--lf Use UNIX-style LF line endings (default)
|
||||||
--crlf Use Windows-style CRLF line endings
|
--crlf Use Windows-style CRLF line endings
|
||||||
|
|
||||||
--mutable Whether the symbol should not be marked as const
|
--mutable Whether the symbol should not be marked as const
|
||||||
--const Whether the symbol should be marked as const (default)
|
--const Whether the symbol should be marked as const (default)
|
||||||
--constexpr Whether the symbol should be marked as constexpr (C++ mode)
|
--constexpr Whether the symbol should be marked as constexpr (C++ mode)
|
||||||
|
|
||||||
--symname NAME Symbol name
|
--symname NAME Symbol name
|
||||||
--namespace NAME Namespace in which the symbol will exist
|
--namespace NAME Namespace in which the symbol will exist
|
||||||
(uses namespace example {} in C++ mode and prepends
|
(uses namespace example {} in C++ mode and prepends
|
||||||
@ -46,5 +48,7 @@ BYTES TYPES FOR ARRAYS:
|
|||||||
--u8 C/C++'s (std::)uint8_t type
|
--u8 C/C++'s (std::)uint8_t type
|
||||||
--i8 C/C++'s (std::)int8_t type
|
--i8 C/C++'s (std::)int8_t type
|
||||||
|
|
||||||
|
MISCELLANEOUS:
|
||||||
|
|
||||||
-h | --help Show this help text
|
-h | --help Show this help text
|
||||||
-v | --version Print the program's build & version information";
|
-v | --version Print the program's build & version information";
|
||||||
|
@ -87,7 +87,7 @@ fn write_header(config: &Config) -> Result<(), HeaderGenerationError> {
|
|||||||
let out_file = OpenOptions::new()
|
let out_file = OpenOptions::new()
|
||||||
.write(true)
|
.write(true)
|
||||||
.truncate(config.overwrite)
|
.truncate(config.overwrite)
|
||||||
.create_new(!config.overwrite)
|
.create(true)
|
||||||
.open(config.output_file_path.clone())
|
.open(config.output_file_path.clone())
|
||||||
.expect("failed to open input file");
|
.expect("failed to open input file");
|
||||||
let mut writer = BufWriter::new(out_file);
|
let mut writer = BufWriter::new(out_file);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user