File tree 4 files changed +42
-38
lines changed
4 files changed +42
-38
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,11 @@ const main = defineCommand({
11
11
cache : ( ) => import ( '#ving/cli/cache.mjs' ) . then ( ( r ) => r . default ) ,
12
12
drizzle : ( ) => import ( '#ving/cli/drizzle.mjs' ) . then ( ( r ) => r . default ) ,
13
13
email : ( ) => import ( '#ving/cli/email.mjs' ) . then ( ( r ) => r . default ) ,
14
+ id : ( ) => import ( '#ving/cli/id.mjs' ) . then ( ( r ) => r . default ) ,
14
15
jobs : ( ) => import ( '#ving/cli/jobs.mjs' ) . then ( ( r ) => r . default ) ,
15
16
messagebus : ( ) => import ( '#ving/cli/messagebus.mjs' ) . then ( ( r ) => r . default ) ,
16
17
record : ( ) => import ( '#ving/cli/record.mjs' ) . then ( ( r ) => r . default ) ,
17
18
schema : ( ) => import ( '#ving/cli/schema.mjs' ) . then ( ( r ) => r . default ) ,
18
- token : ( ) => import ( '#ving/cli/token.mjs' ) . then ( ( r ) => r . default ) ,
19
19
user : ( ) => import ( '#ving/cli/user.mjs' ) . then ( ( r ) => r . default ) ,
20
20
} ,
21
21
} ) ;
Original file line number Diff line number Diff line change
1
+ import { defineCommand , showUsage } from "citty" ;
2
+ import ving from '#ving/index.mjs' ;
3
+ import { stringifyId , parseId } from '#ving/utils/int2str.mjs' ;
4
+
5
+ export default defineCommand ( {
6
+ meta : {
7
+ name : "id" ,
8
+ description : "Convert an ID between integer and string." ,
9
+ } ,
10
+ cleanup : ving . close ,
11
+ args : {
12
+ makeString : {
13
+ type : "number" ,
14
+ description : "Encrypt integer into string" ,
15
+ alias : "s" ,
16
+ } ,
17
+ makeInteger : {
18
+ type : "string" ,
19
+ description : "Decrypt string into integer" ,
20
+ alias : "i" ,
21
+ } ,
22
+ } ,
23
+ async run ( { args, cmd } ) {
24
+ try {
25
+ if ( args . makeString ) {
26
+ console . log ( `${ args . makeString } becomes ${ stringifyId ( args . makeString ) } ` ) ;
27
+ }
28
+ else if ( args . makeInteger ) {
29
+ console . log ( `${ args . makeInteger } back to ${ parseId ( args . makeInteger ) } ` ) ;
30
+ }
31
+ else {
32
+ await showUsage ( cmd , { meta : { name : 'ving.mjs' } } ) ;
33
+ }
34
+ }
35
+ catch ( e ) {
36
+ ving . log ( 'cli' ) . error ( e . message ) ;
37
+ }
38
+ } ,
39
+ } ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ outline: deep
10
10
* NOTE: You should run ` npm i ` as we've added skip32 as a new required module.
11
11
* Fixed some email verification corner case problems.
12
12
* Removed the findObject() utility as Array.prototype.find() essentially works the same way, and this forces better error handling.
13
+ * Removed the token CLI command.
14
+ * Added the id CLI command.
13
15
14
16
## 2024-05-06
15
17
* Updated useVingRecord() to allow for extended actions.
You can’t perform that action at this time.
0 commit comments