@cyklang/cli 0.2.3 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,8 @@ export class UserCommand extends Command {
11
11
  constructor(name: string) {
12
12
  super(name)
13
13
  this.description('manage users in cyk_user table').version('0.1')
14
- this.addCommand(new UserAddCmd())
14
+ this.addCommand(new UserAddCmd('add', 'add a new user'))
15
+ this.addCommand(new UserAddCmd('a', 'add a new user'))
15
16
  this.addCommand(new UserUpdateCmd('update', 'update user by id all fields except password'))
16
17
  this.addCommand(new UserUpdateCmd('u', 'shortcut for (u)pdate'))
17
18
  this.addCommand(new UserDeleteCmd('delete', 'delete user by id and name. Both options are mandatory to avoid typing error'))
@@ -31,18 +32,20 @@ interface Options {
31
32
  disable: boolean | undefined
32
33
  env: string | undefined
33
34
  sort: string | undefined
35
+ lang: string | undefined
34
36
  }
35
37
 
36
38
  class UserAddCmd extends Cmd {
37
- constructor() {
38
- super('add')
39
- this.description('add a new user')
39
+ constructor(name: string, description: string) {
40
+ super(name)
41
+ this.description(description)
40
42
  .requiredOption('-n --name <name>', 'user name')
41
43
  .option('-e --email <email>', 'user email address')
42
44
  .option('-p --passwd <password>', 'initial password')
43
45
  .option('-a --access <acl>', 'access control list')
44
46
  .option('-m --module <module_name>', 'module to launch by default')
45
47
  .option('-d --disable', 'user not abled to connect')
48
+ .option('-l --lang <language>', 'user language')
46
49
  .action(async (options: Options) => {
47
50
  const dbUser = new DBUser()
48
51
  dbUser.name = options.name
@@ -51,6 +54,7 @@ class UserAddCmd extends Cmd {
51
54
  dbUser.access = options.access
52
55
  dbUser.appli = options.module
53
56
  dbUser.disable = options.disable || false
57
+ dbUser.lang = options.lang
54
58
  await this.commandAdd(dbUser, options)
55
59
  })
56
60
  }
@@ -83,7 +87,7 @@ class UserListCmd extends Cmd {
83
87
 
84
88
  const dbClient = new DBClient(this.dbManager)
85
89
  dbClient.selectFromTable('List of users', 'cyk_user',
86
- { fields: 'user_id,user_name,user_email,user_access,user_appli,user_disable', sort: options.sort || '1' })
90
+ { fields: 'user_id,user_name,user_email,user_access,user_appli,user_lang,user_disable', sort: options.sort || '1' })
87
91
 
88
92
  }
89
93
  catch (err) {
@@ -102,6 +106,7 @@ class UserUpdateCmd extends Cmd {
102
106
  .option('-e --email <email>', 'user email address')
103
107
  .option('-a --access <acl>', 'access control list')
104
108
  .option('-m --module <module_name>', 'module to launch by default')
109
+ .option('-l --lang <language>', 'user language')
105
110
  .option('-d --disable', 'user not able to connect')
106
111
  .action(async (options: Options) => {
107
112
  const dbUser = new DBUser()
@@ -110,6 +115,7 @@ class UserUpdateCmd extends Cmd {
110
115
  dbUser.email = options.email
111
116
  dbUser.access = options.access
112
117
  dbUser.appli = options.module
118
+ dbUser.lang = options.lang
113
119
  dbUser.disable = options.disable
114
120
  await this.commandUpdate(dbUser, options)
115
121
  })
@@ -126,6 +132,7 @@ class UserUpdateCmd extends Cmd {
126
132
  if (dbUser2.email !== undefined) dbUser1.email = dbUser2.email
127
133
  if (dbUser2.access !== undefined) dbUser1.access = dbUser2.access
128
134
  if (dbUser2.appli !== undefined) dbUser1.appli = dbUser2.appli
135
+ if (dbUser2.lang !== undefined) dbUser1.lang = dbUser2.lang
129
136
  if (dbUser2.disable !== undefined) dbUser1.disable = dbUser2.disable
130
137
  // logger.debug('dbUser1 before dbUserUpdate : ', dbUser1)
131
138
  await this.dbManager.dbUserUpdate(dbUser1)