feat: allow user to specify csv file to use
This commit is contained in:
parent
f0ce8a4725
commit
2555d5f6c7
6
mod.ts
6
mod.ts
|
@ -1,5 +1,6 @@
|
|||
import { Redmine } from 'bluemine';
|
||||
import * as CSV from 'std:csv';
|
||||
import { CsvEntry } from './type.ts';
|
||||
|
||||
if (import.meta.main) {
|
||||
const endpoint = Deno.env.get('ENDPOINT')
|
||||
|
@ -10,9 +11,8 @@ if (import.meta.main) {
|
|||
|
||||
const redmine = new Redmine({ endpoint, apiKey });
|
||||
|
||||
const file = await Deno.readTextFile(
|
||||
'path',
|
||||
);
|
||||
const file = await Deno.readTextFile(prompt('Full path of the CSV file ?:') ?? '');
|
||||
|
||||
const csv = CSV.parse(file.replaceAll(';', ','), {
|
||||
skipFirstRow: true,
|
||||
}) as CsvEntry[];
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
import { Redmine } from 'bluemine';
|
||||
|
||||
type CsvEntry = {
|
||||
firstname: string;
|
||||
lastname: string;
|
||||
mail: string;
|
||||
};
|
||||
import { CsvEntry } from '../type.ts';
|
||||
|
||||
async function addUsersToGroup(redmine: Redmine, csv: CsvEntry[]) {
|
||||
const users: { id: number; login: string }[] = [];
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
import { Redmine } from 'bluemine';
|
||||
|
||||
type CsvEntry = {
|
||||
firstname: string;
|
||||
lastname: string;
|
||||
mail: string;
|
||||
};
|
||||
import { CsvEntry } from '../type.ts';
|
||||
|
||||
async function createUsers(redmine: Redmine, csv: CsvEntry[]) {
|
||||
const userIds: number[] = [];
|
||||
|
|
Loading…
Reference in a new issue