1
Fork 0
dotfiles/.bauke/Deno.md

53 lines
2.0 KiB
Markdown
Raw Permalink Normal View History

2023-01-27 15:07:29 +00:00
# Deno Scripts
## Scripts
- [`codium-extensions`]: save and install VS Codium extensions using their identifier.
- [`copy-nixos-config`]: copies NixOS configuration from `$BAUKE_DIR/nix/<hostname>/` to `/etc/nixos/`.
- [`desktop-wallpaper`]: desktop wallpaper changer.
- [`drg-data-entry`]: Deep Rock Galactic data tracker.
- [`edit-youtube-video`]: edit a YouTube video via the Data API.
- [`project-avatar`]: image generator for projects.
- [`simple-git-push`]: `git push` with extra semantics.
- [`tauon-controls`]: remote control CLI for Tauon Music Box.
[`codium-extensions`]: ./scripts/codium-extensions.ts
[`copy-nixos-config`]: ./scripts/copy-nixos-config.ts
[`desktop-wallpaper`]: ./scripts/desktop-wallpaper.ts
[`drg-data-entry`]: ./scripts/drg-data-entry.ts
[`edit-youtube-video`]: ./scripts/edit-youtube-video.ts
[`project-avatar`]: ./scripts/project-avatar.ts
[`simple-git-push`]: ./scripts/simple-git-push.ts
[`tauon-controls`]: ./scripts/tauon-controls.ts
2023-03-29 11:41:43 +00:00
## Cliffy
For CLI creation [Cliffy] is used, a Deno-specific framework for handling input and parsing arguments.
* A simple command with a `--file <file>` argument:
```ts
// Assuming the script location is `$BAUKE_DIR/scripts`.
import { Command } from "./dependencies.ts";
const { options } = await new Command()
// CLI information, shown in --help.
.name("example-cli")
.description("Description of the program.")
// Add the --file option with a default value.
.option("-f, --file <file:file>", "Example file", {
default: "example.txt"
})
.parse(Deno.args);
console.log(options.file);
```
[Cliffy]: https://cliffy.io
2023-01-27 15:07:29 +00:00
## Why `bin/` + `scripts/`
Deno has [some issues](https://github.com/denoland/deno/issues/17195) with running files without a file extension (like what you'd want in `bin/`). So instead all the scripts are located in `scripts/` with proper file extensions and the `bin/` files call those scripts using `deno run`.
Though even if Deno didn't have these issues, having massive shebangs would also not be nice, so this setup is fine.