feat: add "no create" option
This commit is contained in:
parent
2907465bae
commit
a73357bee9
8
main.ts
8
main.ts
|
@ -10,6 +10,10 @@ await new Command()
|
|||
.description('Create Redmine users from CSV and add users to a group.')
|
||||
.version('0.1.0')
|
||||
.option('-g, --group <group:string>', 'Name of the group to add users in.')
|
||||
.option(
|
||||
'-o, --only-add [only-add:boolean]',
|
||||
"Don't create users, only add them to a group",
|
||||
)
|
||||
.option('-d, --endpoint <endpoint:string>', 'Redmine server address.', {
|
||||
default: 'https://projets.cohabit.fr/redmine',
|
||||
})
|
||||
|
@ -19,7 +23,7 @@ await new Command()
|
|||
{ required: true },
|
||||
)
|
||||
.arguments('<csv:file>')
|
||||
.action(async ({ group, endpoint, apiKey }, domain) => {
|
||||
.action(async ({ group, endpoint, apiKey, onlyAdd }, domain) => {
|
||||
const redmine = new Redmine({ endpoint, apiKey })
|
||||
|
||||
const file = await Deno.readTextFile(domain)
|
||||
|
@ -28,7 +32,7 @@ await new Command()
|
|||
skipFirstRow: true,
|
||||
}) as CsvEntry[]
|
||||
|
||||
createUsers(redmine, csv)
|
||||
if (!onlyAdd) createUsers(redmine, csv)
|
||||
if (group) {
|
||||
appendToGroup(redmine, csv, prompt('Enter a group name ?: ') ?? '')
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue