Skip to content

Commit

Permalink
feat(flag): Get flags where to read/save from/to
Browse files Browse the repository at this point in the history
Users can change file name and output directory.
  • Loading branch information
5ouma committed Feb 15, 2024
1 parent 03883b5 commit cf8b64a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
15 changes: 4 additions & 11 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
{
"$schema": "https://deno.land/x/deno/cli/schemas/config-file.v1.json",
"fmt": {
"exclude": [
"LICENSE",
".github/**/*.md"
]
"exclude": ["LICENSE", ".github/**/*.md"]
},
"test": {
"include": [
"src/",
"test/"
]
"include": ["src/", "test/"]
},
"tasks": {
"clean": "deno fmt && deno cache --lock-write ./**/*.ts",
"gen": "deno run --allow-read --allow-write ./src/main.ts",
"test": "deno test --allow-read --allow-write"
},
"imports": {
"assert": "https://deno.land/std@0.215.0/assert/mod.ts",
"assert": "https://deno.land/std@0.216.0/assert/mod.ts",
"path": "https://deno.land/[email protected]/path/mod.ts",
"toml": "https://deno.land/[email protected]/toml/mod.ts",
"path": "https://deno.land/[email protected]/path/mod.ts",
"toml": "https://deno.land/[email protected]/toml/mod.ts",
"parse_args": "https://deno.land/[email protected]/cli/parse_args.ts",
"case": "https://deno.land/x/[email protected]/mod.ts",
"xml": "https://deno.land/x/[email protected]/mod.ts"
}
Expand Down
1 change: 1 addition & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import { parseArgs } from "parse_args";
import { resolve } from "path";
import { readTOML, writeXML } from "./libs/mod.ts";
import { Lists } from "./types/mod.ts";

const flags = parseArgs(Deno.args, {
string: ["feeds", "output"],
default: {
feeds: "./feeds.toml",
output: "./outputs",
},
});
flags.feeds = resolve(flags.feeds);
flags.output = resolve(flags.output);

try {
const feeds: Lists = await readTOML("feeds.toml");
await writeXML(feeds, "outputs");
const feeds: Lists = await readTOML(flags.feeds);
await writeXML(feeds, flags.output);
} catch (error) {
console.error(`🚨 ${error.message}`);
Deno.exit(1);
Expand Down

0 comments on commit cf8b64a

Please sign in to comment.