Skip to content

Commit bd60f60

Browse files
committed
fix: handled the case when no any args and paths are passed
1 parent 93bc554 commit bd60f60

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ fn check_conflict(path: &Path) -> bool {
170170
}
171171

172172
fn main() {
173-
// parsing the args
174173
let args = Args::parse();
175174

176175
let paths = args.get_items();
@@ -179,6 +178,14 @@ fn main() {
179178
let dir = args.dir;
180179
let permanent = args.permanent;
181180

181+
// Handling the case where no paths are provided and no subcommand is used
182+
if paths.is_empty() && args.command.is_none() {
183+
eprintln!("{}", "rmxt: missing operand".red());
184+
eprintln!("{}", "Try 'rmxt --help' for more information.".yellow());
185+
return;
186+
}
187+
188+
// purging files from trash if the purge command is used
182189
if args.is_purge() {
183190
let names = args.get_purge_name();
184191
let content_to_purge = match trash::os_limited::list() {
@@ -200,6 +207,7 @@ fn main() {
200207
}
201208
}
202209

210+
// recovering all files from trash if the recover-all command is used
203211
if args.is_recover_all() {
204212
let seconds = args.get_time_recover() * 86400;
205213
let mut content_to_recover = vec![];

0 commit comments

Comments
 (0)