Skip to content

Commit

Permalink
version 0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
elliot40404 committed Oct 6, 2022
1 parent e508c19 commit f76dde4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bonky"
version = "0.3.1"
version = "0.3.2"
edition = "2021"
authors = ["Elliot40404"]
description = "The blazingly fast touch alternative written in rust. Made for the sole purpose to create files."
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Crates.io][crates-shield]][crates-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]

Expand Down Expand Up @@ -101,6 +102,16 @@ Download the binary from the releases page

## Usage

Print Help

```bash
bonk -h
```

```bash
bonk --help
```

Create a file

```bash
Expand Down Expand Up @@ -137,6 +148,7 @@ bonk src/bonky/mod.rs

## Roadmap

- [ ] Handle Non-UTF8 files/folders
- [ ] Add timestamp modification functionality

See the [open issues](https://github.com/othneildrew/Best-README-Template/issues) for a full list of proposed features (and known issues).
Expand Down Expand Up @@ -173,7 +185,9 @@ Distributed under the MIT License. See `LICENSE` for more information.
[forks-shield]: https://img.shields.io/github/forks/elliot40404/bonk.svg?style=for-the-badge
[forks-url]: https://github.com/elliot40404/bonk/network/members
[stars-shield]: https://img.shields.io/github/stars/elliot40404/bonk.svg?style=for-the-badge
[crates-shield]: https://img.shields.io/crates/d/bonky?style=for-the-badge
[stars-url]: https://github.com/elliot40404/bonk/stargazers
[crates-url]: https://crates.io/crates/bonky
[issues-shield]: https://img.shields.io/github/issues/elliot40404/bonk.svg?style=for-the-badge
[issues-url]: https://github.com/elliot40404/bonk/issues
[license-shield]: https://img.shields.io/github/license/elliot40404/bonk.svg?style=for-the-badge
Expand Down
49 changes: 13 additions & 36 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ Example:
);
}

fn main() {
fn try_main() -> Result<(), Box<dyn std::error::Error>> {
if (env::args().len() == 1 || env::args().nth(1).unwrap() == "-h")
|| (env::args().nth(1).unwrap() == "--help")
{
print_help();
return;
}
let args = env::args_os()
.map(PathBuf::from)
Expand All @@ -37,45 +36,23 @@ fn main() {
for arg in &args {
if check_if_dir(arg.to_str().unwrap()) {
if arg.to_str().unwrap().ends_with('/') || arg.to_str().unwrap().ends_with('\\') {
match fs::create_dir_all(arg) {
Ok(_) => {}
Err(_) => {
println!(
"Error: Could not create directory '{}'",
arg.to_str().unwrap()
);
std::process::exit(1);
}
}
fs::create_dir_all(arg)?;
} else {
match fs::create_dir_all(arg.parent().unwrap()) {
Ok(_) => {}
Err(_) => {
println!(
"Error: Could not create directory '{}'",
arg.parent().unwrap().to_str().unwrap()
);
std::process::exit(1);
}
}
fs::create_dir_all(arg.parent().unwrap())?;
if !arg.exists() {
match File::create(arg) {
Ok(_) => {}
Err(_) => {
println!("Error: Could not create file '{}'", arg.to_str().unwrap());
std::process::exit(1);
}
}
File::create(arg)?;
}
}
} else if !arg.exists() {
match File::create(arg) {
Ok(_) => {}
Err(_) => {
println!("Error: Could not create file '{}'", arg.to_str().unwrap());
std::process::exit(1);
}
}
File::create(arg)?;
}
}
Ok(())
}

fn main() {
if let Err(_e) = try_main() {
println!("Something went wrong!");
std::process::exit(1);
}
}

0 comments on commit f76dde4

Please sign in to comment.