Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
WGUNDERWOOD committed May 3, 2024
1 parent 94acf7c commit cea64e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 4 additions & 2 deletions notes.org
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
*** -p Print to STDOUT
*** -v Info verbose
*** -vv Debug verbose
** Log file
** Ignore source lines
*** Line-by-line ignore
*** Block ignore
** Log file
** Documentation
** Tidy up code
** Find todos
** Tests better output
** Better file backup
* Bugs
** Better errors including line numbers in source file
** Handle list items properly
** Handle list items and comments properly
** Do not wrap lines in verbatim environment
** Handle errors due to unwrappable lines
12 changes: 5 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,29 @@ mod tests;
fn main() {
// get arguments
let args = Cli::parse();
let debug = args.debug;
let mut print = args.print;
let filenames = args.filenames;
if debug {
if args.debug {
print = true;
};

// check files are in correct format
assert!(filenames.iter().all(|f| f.ends_with(".tex")
assert!(args.filenames.iter().all(|f| f.ends_with(".tex")
|| f.ends_with(".bib")
|| f.ends_with(".sty")
|| f.ends_with(".cls")));

print_script_name();

for filename in filenames {
if debug {
for filename in args.filenames {
if args.debug {
print_file_name(&filename);
}

// read lines from file
let file =
fs::read_to_string(&filename).expect("Should have read the file");

let new_file = format_file(&file, debug);
let new_file = format_file(&file, args.debug);

if print {
print_file(&new_file);
Expand Down

0 comments on commit cea64e7

Please sign in to comment.