From 4c9cf502d01d306c980edcc3732a48a5ad4854d8 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Mon, 15 Jan 2024 22:54:55 +0100 Subject: [PATCH] feat: export function to mod --- mod.ts | 7 ++++++- src/create_users.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mod.ts b/mod.ts index 2be5471..fc1c319 100644 --- a/mod.ts +++ b/mod.ts @@ -1,6 +1,8 @@ import { Redmine } from 'bluemine' import * as CSV from 'std:csv' import { CsvEntry } from './type.ts' +import { createUsers } from './src/create_users.ts' +import { appendToGroup } from './src/append_to_group.ts' if (import.meta.main) { const endpoint = Deno.env.get('ENDPOINT') @@ -20,10 +22,13 @@ if (import.meta.main) { const redmine = new Redmine({ endpoint, apiKey }) const file = await Deno.readTextFile( - prompt('Full path of the CSV file ?:') ?? '', + prompt('Full path of the CSV file ?: ') ?? '', ) const csv = CSV.parse(file.replaceAll(';', ','), { skipFirstRow: true, }) as CsvEntry[] + + createUsers(redmine, csv) + appendToGroup(redmine, csv, prompt('Enter a group name ?: ') ?? '') } diff --git a/src/create_users.ts b/src/create_users.ts index 11dc206..021706a 100644 --- a/src/create_users.ts +++ b/src/create_users.ts @@ -2,7 +2,7 @@ import { Redmine } from 'bluemine' import { CsvEntry } from '../type.ts' import { capitalize, log, sanitize, toLogin } from '../utils.ts' -async function createUsers( +export async function createUsers( redmine: Redmine, csv: CsvEntry[], ) {