Skip to content

Commit

Permalink
🎈Initial✨
Browse files Browse the repository at this point in the history
  • Loading branch information
Himadu2000 committed May 8, 2021
1 parent 20428f4 commit 4896ad6
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 1 deletion.
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
on:
release:
types: [created]

jobs:
release:
name: release ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [x86_64-pc-windows-gnu, x86_64-unknown-linux-musl]
steps:
- uses: actions/checkout@master
- name: Compile and release
uses: rust-build/rust-build.action@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUSTTARGET: ${{ matrix.target }}
EXTRA_FILES: "README.md LICENSE"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
5 changes: 5 additions & 0 deletions Cargo.lock

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

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "deleter"
version = "0.1.0"
authors = ["Himadu2000 <[email protected]>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# Deleter
A delete program. Use with caution!

A folder delete program. Use with caution!

# How to use

open deleter.exe,
enter folder path to delete, Ex: C:/hello
enter yes and voilà.
11 changes: 11 additions & 0 deletions src/confirm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use std::io;

pub fn request_confirmation(location: &str) -> String {
println!("Are you sure delete, {} | Write (yes)", location);
let mut anwser = String::new();
io::stdin()
.read_line(&mut anwser)
.expect("Failed to read line");
let anwser = anwser.trim();
return anwser.to_string();
}
17 changes: 17 additions & 0 deletions src/delete.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::fs;

pub fn delete(path: &str) {
match remove_directory(path) {
Ok(_value) => {
println!("Your folder: {} has been deleted!", path);
}
Err(error) => {
println!("{}", error)
}
}
}

fn remove_directory(path: &str) -> std::io::Result<()> {
fs::remove_dir_all(path)?;
Ok(())
}
17 changes: 17 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::process;
mod confirm;
mod delete;
mod path;

fn main() {
loop {
let path = path::get_path();
if path == "exit" {
process::exit(0);
}
let confirmation = confirm::request_confirmation(&path);
if confirmation == "yes" {
delete::delete(&path);
}
}
}
14 changes: 14 additions & 0 deletions src/path.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::io;

pub fn get_path() -> String {
println!("Please input your folder location to delete. Write exit to quit.");

let mut location = String::new();

io::stdin()
.read_line(&mut location)
.expect("Failed to read line");

let location = location.trim();
return location.to_string();
}

0 comments on commit 4896ad6

Please sign in to comment.