From 7535a5e0267c9e682b7bc8470206c0597f5ba9a1 Mon Sep 17 00:00:00 2001
From: Evo <85353424+EvolutionX-10@users.noreply.github.com>
Date: Sat, 14 May 2022 12:24:10 +0530
Subject: [PATCH] feat: Added version command & created readme (#25)
* feat: Created help command
* fix: Fixed a typo in version command
* feat: Added version command to index.js & changed export type to default
* chore: Updated version command
* chore: Updated help command
* chore: Updated init command
* feat: Added version shortcut command
* docs: Created README
* chore: Added what @jacobees wanted
* docs: Changed the README description
* docs: Updated README
* docs: Fix what Evo wanted
* revert: Reverted what Evo wanted
* revert: Reverting default export
* revert: Reverting the default export
* revert: Reverted the default export
* feat: Version is now come from package.json
* fix: Fixed experimental error
* chore: Updated what evo wanted
* refractor: Changed v to flag
* feat(v): use flags
* docs: some stuff
Co-authored-by: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com>
---
README.md | 33 +++++++++++++++++++++++++++++++++
src/commands/help.js | 5 ++++-
src/index.js | 2 +-
src/utilities/version.js | 7 +++++++
4 files changed, 45 insertions(+), 2 deletions(-)
create mode 100644 README.md
create mode 100644 src/utilities/version.js
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..8421f36
--- /dev/null
+++ b/README.md
@@ -0,0 +1,33 @@
+# Sern CLI
+
+Our CLI allows you to setup and manage Discord bot projects without writing a single line of code!
+
+😁 **User Friendly**
+💦 **Simple**
+🌱 **Efficient**
+💪 **Powerful**
+
+## Installation
+
+```sh
+npm install -g @sern/cli@latest
+```
+
+```sh
+yarn add -g @sern/cli@latest
+```
+
+```sh
+pnpm add -g @sern/cli@latest
+```
+
+## Getting Started
+
+When you install the CLI, you can use our commands with **sern** prefix.
+
+`sern (opt)`
+
+
+## Setting Up Your Project
+
+#### TODO
diff --git a/src/commands/help.js b/src/commands/help.js
index 21877f5..3aaf857 100644
--- a/src/commands/help.js
+++ b/src/commands/help.js
@@ -1,3 +1,6 @@
-export function help() {
+import { version } from '../utilities/version.js';
+
+export function help({ flags }) {
+ if (flags?.includes('v') || flags?.includes('version')) return version();
console.log('This is the Sern CLI help section.\n\n' + 'Fill me up later!');
}
diff --git a/src/index.js b/src/index.js
index 794aa3a..65453c1 100644
--- a/src/index.js
+++ b/src/index.js
@@ -13,7 +13,7 @@ const args = rawArgs
.split(/ +/)
.filter((e) => !/(--|-)\w+/gm.test(e));
-const cmdName = args[0];
+const cmdName = args[0] || '';
const commands = new Map([
['help', help],
diff --git a/src/utilities/version.js b/src/utilities/version.js
new file mode 100644
index 0000000..ce32ba8
--- /dev/null
+++ b/src/utilities/version.js
@@ -0,0 +1,7 @@
+import { createRequire } from 'module';
+const require = createRequire(import.meta.url);
+const { version: v } = require('../../package.json');
+
+export function version() {
+ console.log(`SernHandler CLI v${v}`);
+}