Compare commits

...

6 commits
0.1.0 ... main

5 changed files with 7 additions and 6 deletions

View file

@ -2,7 +2,8 @@
Create Redmine users from CSV and add users to a group.
⚠️ This project is only a draft, it's working but not intended to be use widely ⚠️
⚠️ This project is only a draft, it's working but not intended to be used widely
⚠️
Binaries are placed in `dist/` for x64.

Binary file not shown.

Binary file not shown.

View file

@ -8,7 +8,7 @@ import { Command } from 'cliffy'
await new Command()
.name('redmine-csv-loader')
.description('Create Redmine users from CSV and add users to a group.')
.version('0.1.0')
.version('0.1.1')
.option('-g, --group <group:string>', 'Name of the group to add users in.')
.option(
'-a, --only-add [only-add:boolean]',
@ -23,10 +23,10 @@ await new Command()
{ required: true },
)
.arguments('<csv:file>')
.action(async ({ group, endpoint, apiKey, onlyAdd }, domain) => {
.action(async ({ group, endpoint, apiKey, onlyAdd }, filePath) => {
const redmine = new Redmine({ endpoint, apiKey })
const file = await Deno.readTextFile(domain)
const file = await Deno.readTextFile(filePath)
const csv = CSV.parse(file.replaceAll(';', ','), {
skipFirstRow: true,
@ -34,7 +34,7 @@ await new Command()
if (!onlyAdd) createUsers(redmine, csv)
if (group) {
appendToGroup(redmine, csv, prompt('Enter a group name ?: ') ?? '')
appendToGroup(redmine, csv, group)
}
})
.parse()

View file

@ -13,7 +13,7 @@ export async function createUsers(
const { user } = await redmine.users.create({
firstname: capitalize(sanitize(firstname)),
lastname: capitalize(sanitize(lastname)),
mail: mail,
mail: mail.toLowerCase(),
login,
sendCreationMail: true,
generatePassword: true,