How to use @swim/args - 10 common examples

To help you get started, we’ve selected a few @swim/args examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github swimos / swim / swim-system-js / swim-mesh-js / @swim / cli / main / index.ts View on Github external
} else if (args.data !== void 0) {
        link(edgeUri, "swim:meta:edge", "dataStats", args.format).open();
      } else if (args.link !== void 0) {
        link(edgeUri, "swim:meta:edge", "linkStats", args.format).open();
      } else {
        link(edgeUri, "swim:meta:edge", "routerStats", args.format).open();
      }
    }
  }
}

function runReflectLog(this: Cmd, args: {[name: string]: string | null | undefined}): void {
  // TODO
}

const linkCmd = Cmd.of("link")
    .desc("stream changes to a lane of a remote node")
    .opt(Opt.of("host").flag("h").arg("hostUri").desc("remote host to link"))
    .opt(Opt.of("node").flag("n").arg("nodeUri").desc("remote node to link"))
    .opt(Opt.of("lane").flag("l").arg("laneUri").desc("lane to link"))
    .opt(Opt.of("format").flag("f").arg("json|recon").desc("event output format"))
    .helpCmd()
    .exec(runLink);

const syncCmd = Cmd.of("sync")
    .desc("stream the current state and changes to a lane of a remote node")
    .opt(Opt.of("host").flag("h").arg("hostUri").desc("remote host to link"))
    .opt(Opt.of("node").flag("n").arg("nodeUri").desc("remote node to link"))
    .opt(Opt.of("lane").flag("l").arg("laneUri").desc("lane to link"))
    .opt(Opt.of("format").flag("f").arg("json|recon").desc("event output format"))
    .helpCmd()
    .exec(runSync);
github swimos / swim / swim-system-js / swim-mesh-js / @swim / cli / main / index.ts View on Github external
}

function runReflectLog(this: Cmd, args: {[name: string]: string | null | undefined}): void {
  // TODO
}

const linkCmd = Cmd.of("link")
    .desc("stream changes to a lane of a remote node")
    .opt(Opt.of("host").flag("h").arg("hostUri").desc("remote host to link"))
    .opt(Opt.of("node").flag("n").arg("nodeUri").desc("remote node to link"))
    .opt(Opt.of("lane").flag("l").arg("laneUri").desc("lane to link"))
    .opt(Opt.of("format").flag("f").arg("json|recon").desc("event output format"))
    .helpCmd()
    .exec(runLink);

const syncCmd = Cmd.of("sync")
    .desc("stream the current state and changes to a lane of a remote node")
    .opt(Opt.of("host").flag("h").arg("hostUri").desc("remote host to link"))
    .opt(Opt.of("node").flag("n").arg("nodeUri").desc("remote node to link"))
    .opt(Opt.of("lane").flag("l").arg("laneUri").desc("lane to link"))
    .opt(Opt.of("format").flag("f").arg("json|recon").desc("event output format"))
    .helpCmd()
    .exec(runSync);

const getCmd = Cmd.of("get")
    .desc("fetch the current state of a lane of a remote node")
    .opt(Opt.of("host").flag("h").arg("hostUri").desc("remote host to link"))
    .opt(Opt.of("node").flag("n").arg("nodeUri").desc("remote node to link"))
    .opt(Opt.of("lane").flag("l").arg("laneUri").desc("lane to link"))
    .opt(Opt.of("format").flag("f").arg("json|recon").desc("event output format"))
    .helpCmd()
    .exec(runGet);
github swimos / swim / swim-system-js / swim-core-js / @swim / build / main / cli.ts View on Github external
}, (reason: any): void => {
    console.log(reason);
  });
}

function runClean(this: Cmd, args: {[name: string]: string | null | undefined}): void {
  Build.load(args.config!, args.devel === null).then((build: Build): void => {
    build.forEachProject(args.projects!, (project: Project): void => {
      project.clean();
    });
  }, (reason: any): void => {
    console.log(reason);
  });
}

const projectsCmd: Cmd = Cmd.of("projects")
    .desc("list projects")
    .exec(runProjects);

const targetsCmd: Cmd = Cmd.of("targets")
    .desc("list transitive target dependencies")
    .opt(Opt.of("projects").flag("p").arg("project[:target}(,project[:target})*").desc("comma-separated list of project[:target} specifiers to list"))
    .exec(runTargets);

const compileCmd = Cmd.of("compile")
    .desc("compile sources")
    .opt(Opt.of("projects").flag("p").arg("project[:target}(,project[:target})*").desc("comma-separated list of project[:target} specifiers to compile"))
    .opt(Opt.of("devel").flag("d").desc("disable minification"))
    .opt(Opt.of("test").flag("t").desc("run unit tests after successful compilation"))
    .opt(Opt.of("tests").arg("pattern").desc("only run tests whose names match this pattern"))
    .opt(Opt.of("doc").desc("build documentation after successful compilation"))
    .exec(runCompile);
github swimos / swim / swim-system-js / swim-core-js / @swim / build / main / cli.ts View on Github external
});
  }, (reason: any): void => {
    console.log(reason);
  });
}

const projectsCmd: Cmd = Cmd.of("projects")
    .desc("list projects")
    .exec(runProjects);

const targetsCmd: Cmd = Cmd.of("targets")
    .desc("list transitive target dependencies")
    .opt(Opt.of("projects").flag("p").arg("project[:target}(,project[:target})*").desc("comma-separated list of project[:target} specifiers to list"))
    .exec(runTargets);

const compileCmd = Cmd.of("compile")
    .desc("compile sources")
    .opt(Opt.of("projects").flag("p").arg("project[:target}(,project[:target})*").desc("comma-separated list of project[:target} specifiers to compile"))
    .opt(Opt.of("devel").flag("d").desc("disable minification"))
    .opt(Opt.of("test").flag("t").desc("run unit tests after successful compilation"))
    .opt(Opt.of("tests").arg("pattern").desc("only run tests whose names match this pattern"))
    .opt(Opt.of("doc").desc("build documentation after successful compilation"))
    .exec(runCompile);

const testCmd = Cmd.of("test")
    .desc("run unit tests")
    .opt(Opt.of("projects").flag("p").arg("project[:target}(,project[:target})*").desc("comma-separated list of project[:target} specifiers to test"))
    .opt(Opt.of("devel").flag("d").desc("disable minification"))
    .opt(Opt.of("tests").arg("pattern").desc("only run tests whose names match this pattern"))
    .exec(runTest);

const docCmd = Cmd.of("doc")
github swimos / swim / swim-system-js / swim-mesh-js / @swim / cli / main / index.ts View on Github external
const reflectLogCmd = Cmd.of("log")
    .desc("stream log events")
    .opt(Opt.of("trace").flag("t").desc("stream trace log messages"))
    .opt(Opt.of("debug").flag("d").desc("stream debug log messages"))
    .opt(Opt.of("info").flag("i").desc("stream info log messages"))
    .opt(Opt.of("warn").flag("w").desc("stream warning log messages"))
    .opt(Opt.of("error").flag("e").desc("stream error log messages"))
    .helpCmd()
    .exec(runReflectLog);

const reflectCmd = Cmd.of("reflect")
    .desc("stream introspection metadata")
    .opt(Opt.of("edge").flag("e").arg("edgeUri").desc("endpoint to introspect"))
    .opt(Opt.of("mesh").flag("m").arg(Arg.of("meshUri").optional(true)).desc("introspect default or specified mesh"))
    .opt(Opt.of("part").flag("p").arg(Arg.of("partKey").optional(true)).desc("introspect default or specified partition"))
    .opt(Opt.of("host").flag("h").arg(Arg.of("hostUri").optional(true)).desc("introspect default or specified host"))
    .opt(Opt.of("node").flag("n").arg("nodeUri").desc("introspect specified node"))
    .opt(Opt.of("lane").flag("l").arg("laneUri").desc("introspect specified lane"))
    .opt(Opt.of("link").flag("k").desc("introspect link behavior"))
    .opt(Opt.of("router").flag("r").desc("introspect router behavior"))
    .opt(Opt.of("data").desc("introspect data behavior"))
    .opt(Opt.of("system").desc("introspect system behavior"))
    .opt(Opt.of("process").desc("introspect process behavior"))
    .opt(Opt.of("stats").flag("s").desc("stream introspection statistics"))
    .opt(Opt.of("format").flag("f").arg("json|recon").desc("event output format"))
    .cmd(reflectLogCmd)
    .helpCmd()
    .exec(runReflect);

const cmd = Cmd.of("swim-cli")
    .cmd(linkCmd)
    .cmd(syncCmd)
github swimos / swim / swim-system-js / swim-mesh-js / @swim / cli / main / index.ts View on Github external
.opt(Opt.of("error").flag("e").desc("stream error log messages"))
    .helpCmd()
    .exec(runReflectLog);

const reflectCmd = Cmd.of("reflect")
    .desc("stream introspection metadata")
    .opt(Opt.of("edge").flag("e").arg("edgeUri").desc("endpoint to introspect"))
    .opt(Opt.of("mesh").flag("m").arg(Arg.of("meshUri").optional(true)).desc("introspect default or specified mesh"))
    .opt(Opt.of("part").flag("p").arg(Arg.of("partKey").optional(true)).desc("introspect default or specified partition"))
    .opt(Opt.of("host").flag("h").arg(Arg.of("hostUri").optional(true)).desc("introspect default or specified host"))
    .opt(Opt.of("node").flag("n").arg("nodeUri").desc("introspect specified node"))
    .opt(Opt.of("lane").flag("l").arg("laneUri").desc("introspect specified lane"))
    .opt(Opt.of("link").flag("k").desc("introspect link behavior"))
    .opt(Opt.of("router").flag("r").desc("introspect router behavior"))
    .opt(Opt.of("data").desc("introspect data behavior"))
    .opt(Opt.of("system").desc("introspect system behavior"))
    .opt(Opt.of("process").desc("introspect process behavior"))
    .opt(Opt.of("stats").flag("s").desc("stream introspection statistics"))
    .opt(Opt.of("format").flag("f").arg("json|recon").desc("event output format"))
    .cmd(reflectLogCmd)
    .helpCmd()
    .exec(runReflect);

const cmd = Cmd.of("swim-cli")
    .cmd(linkCmd)
    .cmd(syncCmd)
    .cmd(getCmd)
    .cmd(reflectCmd)
    .helpCmd();

cmd.parse().run();
github swimos / swim / swim-system-js / swim-core-js / @swim / build / main / cli.ts View on Github external
.opt(Opt.of("devel").flag("d").desc("disable minification"))
    .opt(Opt.of("test").flag("t").desc("run unit tests after successful compilation"))
    .opt(Opt.of("tests").arg("pattern").desc("only run tests whose names match this pattern"))
    .opt(Opt.of("doc").desc("build documentation after successful compilation"))
    .exec(runCompile);

const testCmd = Cmd.of("test")
    .desc("run unit tests")
    .opt(Opt.of("projects").flag("p").arg("project[:target}(,project[:target})*").desc("comma-separated list of project[:target} specifiers to test"))
    .opt(Opt.of("devel").flag("d").desc("disable minification"))
    .opt(Opt.of("tests").arg("pattern").desc("only run tests whose names match this pattern"))
    .exec(runTest);

const docCmd = Cmd.of("doc")
    .desc("generate documentation")
    .opt(Opt.of("projects").flag("p").arg("project[:target}(,project[:target})*").desc("comma-separated list of project[:target} specifiers to document"))
    .opt(Opt.of("devel").flag("d").desc("disable minification"))
    .exec(runDoc);

const watchCmd = Cmd.of("watch")
    .desc("rebuild targets on source change")
    .opt(Opt.of("projects").flag("p").arg("project[:target}(,project[:target})*").desc("comma-separated list of project[:target} specifiers to watch"))
    .opt(Opt.of("devel").flag("d").desc("disable minification"))
    .opt(Opt.of("test").flag("t").desc("run unit tests after successful compilation"))
    .opt(Opt.of("tests").arg("pattern").desc("only run tests whose names match this pattern"))
    .opt(Opt.of("doc").desc("build documentation after successful compilation"))
    .exec(runWatch);

const updateCmd: Cmd = Cmd.of("update")
    .desc("update package versions to match build config")
    .opt(Opt.of("projects").flag("p").arg("project(,project)*").desc("comma-separated list of projects to update"))
    .exec(runUpdate);
github swimos / swim / swim-system-js / swim-mesh-js / @swim / cli / main / index.ts View on Github external
.opt(Opt.of("format").flag("f").arg("json|recon").desc("event output format"))
    .helpCmd()
    .exec(runSync);

const getCmd = Cmd.of("get")
    .desc("fetch the current state of a lane of a remote node")
    .opt(Opt.of("host").flag("h").arg("hostUri").desc("remote host to link"))
    .opt(Opt.of("node").flag("n").arg("nodeUri").desc("remote node to link"))
    .opt(Opt.of("lane").flag("l").arg("laneUri").desc("lane to link"))
    .opt(Opt.of("format").flag("f").arg("json|recon").desc("event output format"))
    .helpCmd()
    .exec(runGet);

const reflectLogCmd = Cmd.of("log")
    .desc("stream log events")
    .opt(Opt.of("trace").flag("t").desc("stream trace log messages"))
    .opt(Opt.of("debug").flag("d").desc("stream debug log messages"))
    .opt(Opt.of("info").flag("i").desc("stream info log messages"))
    .opt(Opt.of("warn").flag("w").desc("stream warning log messages"))
    .opt(Opt.of("error").flag("e").desc("stream error log messages"))
    .helpCmd()
    .exec(runReflectLog);

const reflectCmd = Cmd.of("reflect")
    .desc("stream introspection metadata")
    .opt(Opt.of("edge").flag("e").arg("edgeUri").desc("endpoint to introspect"))
    .opt(Opt.of("mesh").flag("m").arg(Arg.of("meshUri").optional(true)).desc("introspect default or specified mesh"))
    .opt(Opt.of("part").flag("p").arg(Arg.of("partKey").optional(true)).desc("introspect default or specified partition"))
    .opt(Opt.of("host").flag("h").arg(Arg.of("hostUri").optional(true)).desc("introspect default or specified host"))
    .opt(Opt.of("node").flag("n").arg("nodeUri").desc("introspect specified node"))
    .opt(Opt.of("lane").flag("l").arg("laneUri").desc("introspect specified lane"))
    .opt(Opt.of("link").flag("k").desc("introspect link behavior"))
github swimos / swim / swim-system-js / swim-mesh-js / @swim / cli / main / index.ts View on Github external
.helpCmd()
    .exec(runSync);

const getCmd = Cmd.of("get")
    .desc("fetch the current state of a lane of a remote node")
    .opt(Opt.of("host").flag("h").arg("hostUri").desc("remote host to link"))
    .opt(Opt.of("node").flag("n").arg("nodeUri").desc("remote node to link"))
    .opt(Opt.of("lane").flag("l").arg("laneUri").desc("lane to link"))
    .opt(Opt.of("format").flag("f").arg("json|recon").desc("event output format"))
    .helpCmd()
    .exec(runGet);

const reflectLogCmd = Cmd.of("log")
    .desc("stream log events")
    .opt(Opt.of("trace").flag("t").desc("stream trace log messages"))
    .opt(Opt.of("debug").flag("d").desc("stream debug log messages"))
    .opt(Opt.of("info").flag("i").desc("stream info log messages"))
    .opt(Opt.of("warn").flag("w").desc("stream warning log messages"))
    .opt(Opt.of("error").flag("e").desc("stream error log messages"))
    .helpCmd()
    .exec(runReflectLog);

const reflectCmd = Cmd.of("reflect")
    .desc("stream introspection metadata")
    .opt(Opt.of("edge").flag("e").arg("edgeUri").desc("endpoint to introspect"))
    .opt(Opt.of("mesh").flag("m").arg(Arg.of("meshUri").optional(true)).desc("introspect default or specified mesh"))
    .opt(Opt.of("part").flag("p").arg(Arg.of("partKey").optional(true)).desc("introspect default or specified partition"))
    .opt(Opt.of("host").flag("h").arg(Arg.of("hostUri").optional(true)).desc("introspect default or specified host"))
    .opt(Opt.of("node").flag("n").arg("nodeUri").desc("introspect specified node"))
    .opt(Opt.of("lane").flag("l").arg("laneUri").desc("introspect specified lane"))
    .opt(Opt.of("link").flag("k").desc("introspect link behavior"))
    .opt(Opt.of("router").flag("r").desc("introspect router behavior"))
github swimos / swim / swim-system-js / swim-mesh-js / @swim / cli / main / index.ts View on Github external
const linkCmd = Cmd.of("link")
    .desc("stream changes to a lane of a remote node")
    .opt(Opt.of("host").flag("h").arg("hostUri").desc("remote host to link"))
    .opt(Opt.of("node").flag("n").arg("nodeUri").desc("remote node to link"))
    .opt(Opt.of("lane").flag("l").arg("laneUri").desc("lane to link"))
    .opt(Opt.of("format").flag("f").arg("json|recon").desc("event output format"))
    .helpCmd()
    .exec(runLink);

const syncCmd = Cmd.of("sync")
    .desc("stream the current state and changes to a lane of a remote node")
    .opt(Opt.of("host").flag("h").arg("hostUri").desc("remote host to link"))
    .opt(Opt.of("node").flag("n").arg("nodeUri").desc("remote node to link"))
    .opt(Opt.of("lane").flag("l").arg("laneUri").desc("lane to link"))
    .opt(Opt.of("format").flag("f").arg("json|recon").desc("event output format"))
    .helpCmd()
    .exec(runSync);

const getCmd = Cmd.of("get")
    .desc("fetch the current state of a lane of a remote node")
    .opt(Opt.of("host").flag("h").arg("hostUri").desc("remote host to link"))
    .opt(Opt.of("node").flag("n").arg("nodeUri").desc("remote node to link"))
    .opt(Opt.of("lane").flag("l").arg("laneUri").desc("lane to link"))
    .opt(Opt.of("format").flag("f").arg("json|recon").desc("event output format"))
    .helpCmd()
    .exec(runGet);

const reflectLogCmd = Cmd.of("log")
    .desc("stream log events")
    .opt(Opt.of("trace").flag("t").desc("stream trace log messages"))
    .opt(Opt.of("debug").flag("d").desc("stream debug log messages"))

@swim/args

Composable command line argument parser

Apache-2.0
Latest version published 1 month ago

Package Health Score

77 / 100
Full package analysis

Similar packages