From 2bd2a6f09c7d78b794e6cce7b98ba886d370c377 Mon Sep 17 00:00:00 2001 From: Hugo Josefson Date: Fri, 15 Jul 2022 14:36:06 +0200 Subject: [PATCH] docs: describe example commands --- README.md | 5 +++++ example.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 37e8b80..94f51c9 100644 --- a/README.md +++ b/README.md @@ -9,21 +9,26 @@ Simple run function to execute shell commands in Deno. import { run } from "https://deno.land/x/run_simple/mod.ts"; +// Simple command const dir: string = await run("ls -l"); console.log(dir); +// Command with variable argument const uid = 1000; const idLine: string = await run(["id", uid]); console.log(idLine); +// An argument contains spaces const remoteHost = "10.20.30.40"; const remoteCommand = "ps -ef --forest"; const remoteProcessTree: string = await run(["ssh", remoteHost, remoteCommand]); +// Supply STDIN to the command const contents = `# Remote file This will be the contents of the remote file. `; +// In this case, ignore response string await run( ["ssh", remoteHost, "bash", "-c", "cat > remote_file.md"], { stdin: contents }, diff --git a/example.ts b/example.ts index 59c22b6..867c112 100644 --- a/example.ts +++ b/example.ts @@ -1,20 +1,25 @@ import { run } from "./mod.ts"; +// Simple command const dir: string = await run("ls -l"); console.log(dir); +// Command with variable argument const uid = 1000; const idLine: string = await run(["id", uid]); console.log(idLine); +// An argument contains spaces const remoteHost = "10.20.30.40"; const remoteCommand = "ps -ef --forest"; const remoteProcessTree: string = await run(["ssh", remoteHost, remoteCommand]); +// Supply STDIN to the command const contents = `# Remote file This will be the contents of the remote file. `; +// In this case, ignore response string await run( ["ssh", remoteHost, "bash", "-c", "cat > remote_file.md"], { stdin: contents },