REMEMBER: Breaking the problem up

   1. Creating the CLI options.  These are things we can parse
      from the command line interface.

   +----------+
   | cli opts | ->
   +----------+
















TypeScript

I am going to make some basic assumptions that everyone watching this is familiar with TypeScript and there are probably some of you out there that are even better than me at it.

CLI Argument parsing

There is no reason why you cannot use any other argument parser. I literally saw about 15 of them and played a game of pick whichever one felt good in the moment!

  • NodeJS : command-line-args
    • simple, easy to use.
















Lets setup our project

To make it easy, set it up any way you want. Personally here is how my folder structer will work.

~/projects/projector-typescript
~/projects/projector-go
~/projects/projector-rust

Reason being is that this will make it easiest for me to swap back and forth betwixt the projects

















I use tmux, btw

















I use vim, btw

















I use dvorak, btw

















I use a Kinesis 360, btw

















So to get started lets create the project

Create it where you like

yarn init -y
yarn add command-line-args @types/command-line-args
yarn add ts-node typescript @types/node
git init
echo "node_modules" > .gitignore
mkdir src
vim . # you can open up other less awesome editors

Yes, of course i am not going to setup a build to make this into an shebang'd script.

Example of CLI (wont match exactly)

Here is an example i'll be putting under src/opts.ts

import cli from "command-line-args";

export type ProjectorOptions = {
    pwd?: string; // projector --pwd ...
    config?: string; // projector --config ...
    arguments?: string[];
}

export default function getOptions(): ProjectorOptions {
    return cli([
        { name: 'config', type: String },
        { name: 'pwd', type: String },
        { name: 'arguments', type: String, defaultOption: true, multiple: true },
    ]) as ProjectorOptions;
}
















So lets build it again, but in Go!

This is what I think is very valuable. You have a concrete idea of what we are doing, now we do it in a language you are not familiar.