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 { Redmine } from 'bluemine';
|
||||||
import * as CSV from 'std:csv';
|
import * as CSV from 'std:csv';
|
||||||
|
import { CsvEntry } from './type.ts';
|
||||||
|
|
||||||
if (import.meta.main) {
|
if (import.meta.main) {
|
||||||
const endpoint = Deno.env.get('ENDPOINT')
|
const endpoint = Deno.env.get('ENDPOINT')
|
||||||
|
@ -10,9 +11,8 @@ if (import.meta.main) {
|
||||||
|
|
||||||
const redmine = new Redmine({ endpoint, apiKey });
|
const redmine = new Redmine({ endpoint, apiKey });
|
||||||
|
|
||||||
const file = await Deno.readTextFile(
|
const file = await Deno.readTextFile(prompt('Full path of the CSV file ?:') ?? '');
|
||||||
'path',
|
|
||||||
);
|
|
||||||
const csv = CSV.parse(file.replaceAll(';', ','), {
|
const csv = CSV.parse(file.replaceAll(';', ','), {
|
||||||
skipFirstRow: true,
|
skipFirstRow: true,
|
||||||
}) as CsvEntry[];
|
}) as CsvEntry[];
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
import { Redmine } from 'bluemine';
|
import { Redmine } from 'bluemine';
|
||||||
|
import { CsvEntry } from '../type.ts';
|
||||||
type CsvEntry = {
|
|
||||||
firstname: string;
|
|
||||||
lastname: string;
|
|
||||||
mail: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
async function addUsersToGroup(redmine: Redmine, csv: CsvEntry[]) {
|
async function addUsersToGroup(redmine: Redmine, csv: CsvEntry[]) {
|
||||||
const users: { id: number; login: string }[] = [];
|
const users: { id: number; login: string }[] = [];
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
import { Redmine } from 'bluemine';
|
import { Redmine } from 'bluemine';
|
||||||
|
import { CsvEntry } from '../type.ts';
|
||||||
type CsvEntry = {
|
|
||||||
firstname: string;
|
|
||||||
lastname: string;
|
|
||||||
mail: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
async function createUsers(redmine: Redmine, csv: CsvEntry[]) {
|
async function createUsers(redmine: Redmine, csv: CsvEntry[]) {
|
||||||
const userIds: number[] = [];
|
const userIds: number[] = [];
|
||||||
|
|
Loading…
Reference in a new issue