Skip to content

Commit

Permalink
docs: describe example commands
Browse files Browse the repository at this point in the history
  • Loading branch information
hugojosefson committed Jul 15, 2022
1 parent 71b384a commit 2bd2a6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
5 changes: 5 additions & 0 deletions example.ts
Original file line number Diff line number Diff line change
@@ -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 },
Expand Down

0 comments on commit 2bd2a6f

Please sign in to comment.