PolymerLabs / arcs

Arcs
BSD 3-Clause "New" or "Revised" License
57 stars 35 forks source link

Modernize cli scripts in Arcs #2802

Open lindner opened 5 years ago

lindner commented 5 years ago

Arcs has a number of node shell scripts. Each one is bespoke and adding a new script or options is not well defined. Here are some issues with the current state

Here is a non-exhaustive list of scripts in the repo:

A desirable end state would satisfy the following requirements

I evaluated available options and found that there are three main tools that are in active use in the Node ecosystem:

The following factors were weighed:

To that end I propose that we adopt commander as our default CLI solution for running code in node environments.

A prototype exists here:

https://github.com/lindner/arcs/commit/714a11a15b8a1e96c3bc61350d788b642da4176f

After build and npm link you will have an arcs command in your path. There is a main arcs executable and each subcommand is installed as arcs-subcommand

Running arcs --help shows

Usage: arcs [options] [command]

Arcs System

Options:
  -V, --version  output the version number
  -h, --help     output usage information

Commands:
  init           Initialize Arcs
  status         Show the arcs status
  export         Export Repo Contents
  ingest         Ingest Data into Arcs
  flowcheck      Analyze and Diagnose Dataflow
  manifest       Handle Manifest files
  help [cmd]     display help for [cmd]

Here's an example of src/cli/arcs-manifest.ts

#!/usr/bin/env -S node --require esm --require source-map-support/register
// ...
commander.command('parse <filename>')
    .description('Parse a Manifest')
    .action(async (filename) => {
         // ....
    })
    .parse(process.argv);
lindner commented 5 years ago

Would appreciate comments on this proposal. Assigning to owner of infra @raulverag .

shaper commented 5 years ago

Thanks for exploring this! It sounds interesting and I can see it being useful during exploration of data import and making it easier for folks to learn about how to install, update, and work with the Arcs system. I defer to @raulverag but wanted to briefly note some initial thoughts:

lindner commented 5 years ago

@shaper thanks for the feedback.

I think we can address your concerns:

Also note that I took some inspiration from the js-ipfs CLI. It's well thought out and works nicely.

lindner commented 5 years ago

Also of note is that if we implement a CLI system we can drop usage of npm start

shans commented 5 years ago

This is an interesting direction to think about going in; I don't see a strong value proposition in doing it now. Specifically, this doesn't seem to contribute to our current goals. While I agree with @shaper that this would make an exploration of data import easier, I can't see how that contributes towards the current goal of a data import MMVP.

It isn't clear that doing this would actually have much impact on onboarding users in other ways; particularly, it sounds like sigh would remain basically the same as it currently is from a usage perspective.

When we do have spare capacity to move on something like this (or if you decide you'd like to do it as a 20%-style thing) I think you will need to ensure that we don't at any stage support multiple different command-line arg parsers, to make sure we don't take a step backwards in this regard.

Some specific questions/observations:

raulverag commented 5 years ago

Another reason I think we should hold off on this is that we will relatively soon need to start distinguishing clearly between tools and docs for people like ourselves who are working on the Arcs system, and tools and docs for developers of Particles and Recipes. Piotr even mentioned an Arcs Developer Kit, which I think makes a lot of sense. We will need this for onboarding 3P developers, and it will be important to get it right early, as a clunky early ADK can be a disaster for adoption. So while I agree that our current set of tools is a bit messy, it doesn't cause very much friction, so I would suggest we clean it up as part of a broader design that includes the tools to be included in an ADK.

Also, am I the owner of infra? I don't mind, but I don't particularly recall signing up for this.

lindner commented 5 years ago

Okay, will defer this for now. (And @raulverag with your sigh and build expertise it seemed that you were owning infra, sorry!)

That said, I did recently need to fix the spotify importer so I converted it to a command line tool using some (but not all) of the above concepts:

https://github.com/PolymerLabs/arcs/pull/2870

One nice part is that it doesn't require sigh to set up the environment (at least on Unix/Mac)

I do hope that this exploration is useful and that we learn something from the effort.