feat: add "no create" option

This commit is contained in:
Julien Oculi 2024-01-15 23:32:51 +01:00
parent 2907465bae
commit a73357bee9

View file

@ -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 ?: ') ?? '')
}