diff --git a/README.md b/README.md index c8c4f6c..da99b41 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,10 @@ Options: -c, --with-categories view categories (default: false) -f, --with-formats view formats (default: false) -e, --with-companies view speakers company (default: false) + -a, --with-addresses view speakers address (default: false) -l, --with-languages view talks language (default: false) -t, --titlelength the title length (default: 100) + -w, --links view links -x, --export export into tsv file -h, --help display help for command ``` diff --git a/package.json b/package.json index 96f76f3..532cf8d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "choc", - "version": "0.1.3", + "version": "0.1.4", "module": "src/index.ts", "type": "module", "devDependencies": { diff --git a/src/DTO.ts b/src/DTO.ts index 8652492..db6cf52 100644 --- a/src/DTO.ts +++ b/src/DTO.ts @@ -10,7 +10,17 @@ export const DTO = ( ): TalkRow[] => talks.flatMap( ( - { title, speakers, formats, categories, rating, loves, hates, language }, + { + id, + title, + speakers, + formats, + categories, + rating, + loves, + hates, + language, + }, position: number ) => { const lines: TalkRow[] = []; @@ -24,6 +34,11 @@ export const DTO = ( addCompanies = { company: speakerHash.get(uid)?.company, }; + let addAddresses = {}; + if (options.withAddresses) + addAddresses = { + addresses: speakerHash.get(uid)?.address, + }; if (i === 0) { const line = { position: position + 1, @@ -44,22 +59,31 @@ export const DTO = ( addLanguages = { language: language, }; + let addLink = {}; + if (options.links) { + addLink = { + link: `https://conference-hall.io/organizer/event/${options.links}/proposals/${id}`, + }; + } lines.push({ ...line, ...addFormats, ...addCategories, speakers: speakerHash.get(uid)?.name, ...addCompanies, + ...addAddresses, ...addLanguages, rating: Number(Number(rating ?? "0").toFixed(2)), loves, hates, + ...addLink, }); } else lines.push({ title: titleSplit.shift() ?? "", speakers: speakerHash.get(uid)?.name, ...addCompanies, + ...addAddresses, }); }); titleSplit.forEach((title) => lines.push({ title })); @@ -106,6 +130,19 @@ export const DTOExport = ( .map((uid: string) => speakerHash.get(uid)?.company) .join(", "), }; + let addAddresses = {}; + if (options.withAddresses) + addAddresses = { + address: speakers + .map((uid: string) => speakerHash.get(uid)?.address) + .join(", "), + }; + let addLink = {}; + if (options.links) { + addLink = { + link: `https://conference-hall.io/organizer/event/${options.links}/proposals/${id}`, + }; + } return { ...line, ...addFormats, @@ -114,10 +151,12 @@ export const DTOExport = ( .map((uid: string) => speakerHash.get(uid)?.name) .join(", "), ...addCompanies, + ...addAddresses, ...addLanguages, rating: Number(Number(rating ?? "0").toFixed(2)), loves, hates, + ...addLink, }; } ); diff --git a/src/choc.ts b/src/choc.ts index 79d4117..b6f3a22 100644 --- a/src/choc.ts +++ b/src/choc.ts @@ -16,10 +16,11 @@ const choc = async (file: string, options: Options) => { formatsHash.set(id, removeEmojis(name)); }); const speakerHash = new Map(); - (speakers as Speaker[]).forEach(({ uid, displayName, company }) => { + (speakers as Speaker[]).forEach(({ uid, displayName, company, address }) => { speakerHash.set(uid, { name: removeEmojis(displayName), company: removeEmojis(company ?? ""), + address: removeEmojis(address?.formattedAddress ?? ""), }); }); const categoriesHash = new Map(); diff --git a/src/index.ts b/src/index.ts index a372dde..3b72aec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,8 +21,10 @@ program .option("-c, --with-categories", "view categories", false) .option("-f, --with-formats", "view formats", false) .option("-e, --with-companies", "view speakers company", false) + .option("-a, --with-addresses", "view speakers address", false) .option("-l, --with-languages", "view talks language", false) .option("-t, --titlelength ", "the title length", myParseInt, 100) + .option("-w, --links ", "view links") .option("-x, --export ", "export into tsv file") .action(choc); diff --git a/src/types.ts b/src/types.ts index 1c96cb1..dd4e524 100644 --- a/src/types.ts +++ b/src/types.ts @@ -18,14 +18,21 @@ export type Speaker = { uid: string; displayName: string; company: string; + address: Address; }; export type SpeakerData = { name: string; company: string; + address: string; }; +export type Address { + formattedAddress: string; +} + export type Talk = { + id: string; title: string; speakers: string[]; formats: string; @@ -41,6 +48,8 @@ export type Options = { withCompanies: boolean; withFormats: boolean; withLanguages: boolean; + withAddresses: boolean; titlelength: number; + links: string; export?: string; };