Skip to content

Commit

Permalink
Finish first implementation of CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
Ackuq committed Sep 17, 2023
1 parent a0c6b36 commit 9141995
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
7 changes: 6 additions & 1 deletion packages/party-data/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { select } from "@inquirer/prompts";
import { readNotCategorizedStandpoints, readSubjects } from ".";
import {
readNotCategorizedStandpoints,
readSubjects,
updateStandpoint,
} from ".";

async function categorize() {
const subjects = readSubjects();
Expand All @@ -19,6 +23,7 @@ ${standpoint.opinions.map((opinion) => `\t${opinion}`).join("\n")}`,
choices: subjectChoices,
});
standpoint.subject = choice;
updateStandpoint(standpoint.party, standpoint);
}
}

Expand Down
9 changes: 8 additions & 1 deletion packages/party-data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@ export function writePartyData(
fs.writeFileSync(fileName, JSON.stringify(storedData, null, 2));
}

// export function updateSubject(abbreviation: string, standpoint: Standpoint) {}
export function updateStandpoint(abbreviation: string, standpoint: Standpoint) {
const fileName = partyFileName(abbreviation);
const storedData = JSON.parse(
fs.readFileSync(fileName).toString(),
) as PartyData;
storedData[standpoint.url] = standpoint;
fs.writeFileSync(fileName, JSON.stringify(storedData, null, 2));
}

function readSubjectData() {
return JSON.parse(fs.readFileSync(SUBJECTS_FILE).toString()) as SubjectData;
Expand Down
12 changes: 8 additions & 4 deletions packages/party-data/parties/s.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"title": "Abort",
"url": "https://www.socialdemokraterna.se/var-politik/a-till-o/abort",
"fetchDate": "2023-09-17T17:52:39.845Z",
"party": "s"
"party": "s",
"subject": "Vård och Omsorg"
},
"https://www.socialdemokraterna.se/var-politik/a-till-o/a-kassan": {
"opinions": [
Expand All @@ -21,7 +22,8 @@
"title": "A-kassan",
"url": "https://www.socialdemokraterna.se/var-politik/a-till-o/a-kassan",
"fetchDate": "2023-09-17T17:52:39.358Z",
"party": "s"
"party": "s",
"subject": "Trygghetssystem och Välfärd"
},
"https://www.socialdemokraterna.se/var-politik/a-till-o/alkohol": {
"opinions": [
Expand All @@ -37,7 +39,8 @@
"title": "Alkohol",
"url": "https://www.socialdemokraterna.se/var-politik/a-till-o/alkohol",
"fetchDate": "2023-09-17T17:52:38.147Z",
"party": "s"
"party": "s",
"subject": "Vård och Omsorg"
},
"https://www.socialdemokraterna.se/var-politik/a-till-o/antirasism-och-framlingsfientlighet": {
"opinions": [
Expand All @@ -51,7 +54,8 @@
"title": "Antirasism och främlingsfientlighet",
"url": "https://www.socialdemokraterna.se/var-politik/a-till-o/antirasism-och-framlingsfientlighet",
"fetchDate": "2023-09-17T17:52:39.028Z",
"party": "s"
"party": "s",
"subject": "Jämställdhet och diskriminering"
},
"https://www.socialdemokraterna.se/var-politik/a-till-o/apotek": {
"opinions": [
Expand Down

0 comments on commit 9141995

Please sign in to comment.