Skip to content

Commit

Permalink
feat: rustraf cli
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnvanhulle authored Jun 14, 2022
1 parent 68ae8e7 commit 1d9cb25
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
33 changes: 32 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
console.log("Not implemented yet");
#!/usr/bin/env node

const yargs = require("yargs/yargs");
const { hideBin } = require("yargs/helpers");
const { removeFile } = require("../index");

const commands = hideBin(process.argv);

const builder = yargs(process.argv.slice(2))
.scriptName("rustraf")
.command(
"$0",
"rustraf <path> [<path> ...]",
() => {},
() => {
const [file] = commands;
try {
removeFile(file);
} catch (e) {
console.error("Could not delete ", file);
}
}
)
.showHelpOnFail(true)
.demandCommand(1)
.version();

if (commands.length === 0) {
builder.showHelp().parse();
} else {
builder.parse();
}
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
"standard-version": "^9.5.0"
},
"optionalDependencies": {
"@rustraf/core-win32-x64-msvc": "0.0.9",
"@rustraf/core-darwin-arm64": "0.0.9",
"@rustraf/core-darwin-x64": "0.0.9",
"@rustraf/core-linux-x64-gnu": "0.0.9",
"@rustraf/core-darwin-arm64": "0.0.9"
"@rustraf/core-win32-x64-msvc": "0.0.9"
},
"engines": {
"node": ">=14.18"
Expand All @@ -67,5 +67,8 @@
"bugs": {
"url": "https://github.com/stijnvanhulle/rustraf/issues"
},
"homepage": "https://github.com/stijnvanhulle/rustraf#readme"
}
"homepage": "https://github.com/stijnvanhulle/rustraf#readme",
"dependencies": {
"yargs": "^17.5.1"
}
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2659,7 +2659,7 @@ yargs@^16.0.0, yargs@^16.2.0:
y18n "^5.0.5"
yargs-parser "^20.2.2"

yargs@^17.0.0, yargs@^17.3.1:
yargs@^17.0.0, yargs@^17.3.1, yargs@^17.5.1:
version "17.5.1"
resolved "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz#e109900cab6fcb7fd44b1d8249166feb0b36e58e"
integrity sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==
Expand Down

0 comments on commit 1d9cb25

Please sign in to comment.