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.')
|
.description('Create Redmine users from CSV and add users to a group.')
|
||||||
.version('0.1.0')
|
.version('0.1.0')
|
||||||
.option('-g, --group <group:string>', 'Name of the group to add users in.')
|
.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.', {
|
.option('-d, --endpoint <endpoint:string>', 'Redmine server address.', {
|
||||||
default: 'https://projets.cohabit.fr/redmine',
|
default: 'https://projets.cohabit.fr/redmine',
|
||||||
})
|
})
|
||||||
|
@ -19,7 +23,7 @@ await new Command()
|
||||||
{ required: true },
|
{ required: true },
|
||||||
)
|
)
|
||||||
.arguments('<csv:file>')
|
.arguments('<csv:file>')
|
||||||
.action(async ({ group, endpoint, apiKey }, domain) => {
|
.action(async ({ group, endpoint, apiKey, onlyAdd }, domain) => {
|
||||||
const redmine = new Redmine({ endpoint, apiKey })
|
const redmine = new Redmine({ endpoint, apiKey })
|
||||||
|
|
||||||
const file = await Deno.readTextFile(domain)
|
const file = await Deno.readTextFile(domain)
|
||||||
|
@ -28,7 +32,7 @@ await new Command()
|
||||||
skipFirstRow: true,
|
skipFirstRow: true,
|
||||||
}) as CsvEntry[]
|
}) as CsvEntry[]
|
||||||
|
|
||||||
createUsers(redmine, csv)
|
if (!onlyAdd) createUsers(redmine, csv)
|
||||||
if (group) {
|
if (group) {
|
||||||
appendToGroup(redmine, csv, prompt('Enter a group name ?: ') ?? '')
|
appendToGroup(redmine, csv, prompt('Enter a group name ?: ') ?? '')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue