From c4a082031e1a51ae7c1a46776fafca9432e7badb Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sat, 1 Mar 2025 19:19:28 +0000 Subject: [PATCH] feat(cli): Add CLI support with command parsing and version display --- changelog.md | 7 +++++++ package.json | 4 +++- pnpm-lock.yaml | 13 +++++++++++++ ts/00_commitinfo_data.ts | 2 +- ts/cli.ts | 21 +++++++++++++++++++++ ts/index.ts | 9 +++++++++ ts/plugins.ts | 2 ++ 7 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 ts/cli.ts diff --git a/changelog.md b/changelog.md index f1e0ecb..4ea9323 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2025-03-01 - 1.3.0 - feat(cli) +Add CLI support with command parsing and version display + +- Added a basic CLI interface using smartcli. +- Implemented command parsing with a 'restart' command. +- Integrated project version display in the CLI. + ## 2025-03-01 - 1.2.0 - feat(core) Introduce ProcessMonitor with memory management and spawning features diff --git a/package.json b/package.json index edf5e6c..f570670 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "scripts": { "test": "(tstest test/ --web)", "build": "(tsbuild --web --allowimplicitany)", - "buildDocs": "(tsdoc)" + "buildDocs": "(tsdoc)", + "start": "(tsrun ./cli.ts -v)" }, "devDependencies": { "@git.zone/tsbuild": "^2.1.25", @@ -22,6 +23,7 @@ "@types/node": "^22.13.8" }, "dependencies": { + "@push.rocks/projectinfo": "^5.0.2", "@push.rocks/smartcli": "^4.0.11", "@push.rocks/smartpath": "^5.0.18", "pidusage": "^4.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1e69f62..1f37ec3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@push.rocks/projectinfo': + specifier: ^5.0.2 + version: 5.0.2 '@push.rocks/smartcli': specifier: ^4.0.11 version: 4.0.11 @@ -710,6 +713,9 @@ packages: '@push.rocks/mongodump@1.0.8': resolution: {integrity: sha512-oDufyjNBg8I50OaJvbHhc0RnRpJQ544dr9her0G6sA8JmI3hD2/amTdcPLVIX1kzYf5GsTUKeWuRaZgdNqz3ew==} + '@push.rocks/projectinfo@5.0.2': + resolution: {integrity: sha512-zzieCal6jwR++o+fDl8gMpWkNV2cGEsbT96vCNZu/H9kr0iqRmapOiA4DFadkhOnhlDqvRr6TPaXESu2YUbI8Q==} + '@push.rocks/qenv@6.1.0': resolution: {integrity: sha512-1FUFMlSVwFSFg8LbqfkzJ2LLP4lMGApUtgOpsvrde6+AxBmB4gjoNgCUH7z3xXfDAtYqcrtSELXBNE0xVL1MqQ==} @@ -5412,6 +5418,13 @@ snapshots: transitivePeerDependencies: - aws-crt + '@push.rocks/projectinfo@5.0.2': + dependencies: + '@push.rocks/smartfile': 10.0.41 + '@push.rocks/smartpath': 5.0.18 + '@push.rocks/smartpromise': 4.2.3 + '@push.rocks/smartstring': 4.0.15 + '@push.rocks/qenv@6.1.0': dependencies: '@api.global/typedrequest': 3.1.10 diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index f304609..4c1779d 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/tspm', - version: '1.2.0', + version: '1.3.0', description: 'a no fuzz process manager' } diff --git a/ts/cli.ts b/ts/cli.ts new file mode 100644 index 0000000..4dcd933 --- /dev/null +++ b/ts/cli.ts @@ -0,0 +1,21 @@ +import * as plugins from './plugins.js'; +import * as paths from './paths.js'; + +export const run = async () => { + const tspmProjectinfo = new plugins.projectinfo.ProjectInfo(paths.packageDir); + + const smartcliInstance = new plugins.smartcli.Smartcli(); + smartcliInstance.addVersion(tspmProjectinfo.npm.version); + + smartcliInstance.standardCommand().subscribe({ + next: (argvArg) => { + console.log(`Please specify a command.`) + }, + }); + + smartcliInstance.addCommand('restart').subscribe({ + + }) + + smartcliInstance.startParse(); +} \ No newline at end of file diff --git a/ts/index.ts b/ts/index.ts index 01f12a3..69b5983 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,2 +1,11 @@ export * from './classes.tspm.js'; export * from './classes.processmonitor.js'; + +import * as cli from './cli.js'; + +/** + * called to run as cli + */ +export const runCli = async () => { + await cli.run(); +} \ No newline at end of file diff --git a/ts/plugins.ts b/ts/plugins.ts index 5e71080..afad6f7 100644 --- a/ts/plugins.ts +++ b/ts/plugins.ts @@ -8,10 +8,12 @@ export { } // @push.rocks scope +import * as projectinfo from '@push.rocks/projectinfo'; import * as smartpath from '@push.rocks/smartpath'; import * as smartcli from '@push.rocks/smartcli'; export { + projectinfo, smartpath, smartcli, }