From 1d9cb251eafcde7cb8e18869ba10128606b26314 Mon Sep 17 00:00:00 2001 From: Stijn Van Hulle Date: Tue, 14 Jun 2022 12:30:18 +0000 Subject: [PATCH] feat: rustraf cli --- bin/cli.js | 33 ++++++++++++++++++++++++++++++++- package.json | 11 +++++++---- yarn.lock | 2 +- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index 93c6e05..836c802 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -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 [ ...]", + () => {}, + () => { + 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(); +} diff --git a/package.json b/package.json index efd15f7..a061496 100644 --- a/package.json +++ b/package.json @@ -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" @@ -67,5 +67,8 @@ "bugs": { "url": "https://github.com/stijnvanhulle/rustraf/issues" }, - "homepage": "https://github.com/stijnvanhulle/rustraf#readme" -} \ No newline at end of file + "homepage": "https://github.com/stijnvanhulle/rustraf#readme", + "dependencies": { + "yargs": "^17.5.1" + } +} diff --git a/yarn.lock b/yarn.lock index 7198843..12418a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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==