diff --git a/docs/api/hilbish/_index.md b/docs/api/hilbish/_index.md index 98b8d24..5aa7045 100644 --- a/docs/api/hilbish/_index.md +++ b/docs/api/hilbish/_index.md @@ -499,7 +499,7 @@ As a boolean, it specifies whether the command should use standard output or ret #### Example ```lua -This code is the same as `ls -l | wc -l` +-- This code is the same as `ls -l | wc -l` local fs = require 'fs' local pr, pw = fs.pipe() hilbish.run('ls -l', { diff --git a/docs/api/hilbish/hilbish.jobs.md b/docs/api/hilbish/hilbish.jobs.md new file mode 100644 index 0000000..fe3978f --- /dev/null +++ b/docs/api/hilbish/hilbish.jobs.md @@ -0,0 +1,146 @@ +--- +title: Module hilbish.jobs +description: background job management +layout: doc +menu: + docs: + parent: "API" +--- + +## Introduction + +Manage interactive jobs in Hilbish via Lua. + +Jobs are the name of background tasks/commands. A job can be started via +interactive usage or with the functions defined below for use in external runners. + +## Functions +||| +|----|----| +|add(cmdstr, args, execPath)|Creates a new job. This function does not run the job. This function is intended to be| +|all() -> table[@Job]|Returns a table of all job objects.| +|disown(id)|Disowns a job. This simply deletes it from the list of jobs without stopping it.| +|get(id) -> @Job|Get a job object via its ID.| +|last() -> @Job|Returns the last added job to the table.| + +
+
+

+hilbish.jobs.add(cmdstr, args, execPath) + + + +

+ +Creates a new job. This function does not run the job. This function is intended to be +used by runners, but can also be used to create jobs via Lua. Commanders cannot be ran as jobs. + +#### Parameters +`string` **`cmdstr`** +String that a user would write for the job + +`table` **`args`** +Arguments for the commands. Has to include the name of the command. + +`string` **`execPath`** +Binary to use to run the command. Needs to be an absolute path. + +#### Example +```lua +hilbish.jobs.add('go build', {'go', 'build'}, '/usr/bin/go') +``` +
+ +
+
+

+hilbish.jobs.all() -> table[Job] + + + +

+ +Returns a table of all job objects. + +#### Parameters +This function has no parameters. +
+ +
+
+

+hilbish.jobs.disown(id) + + + +

+ +Disowns a job. This simply deletes it from the list of jobs without stopping it. + +#### Parameters +`number` **`id`** + + +
+ +
+
+

+hilbish.jobs.get(id) -> Job + + + +

+ +Get a job object via its ID. + +#### Parameters +This function has no parameters. +
+ +
+
+

+hilbish.jobs.last() -> Job + + + +

+ +Returns the last added job to the table. + +#### Parameters +This function has no parameters. +
+ +## Types +
+ +## Job +The Job type describes a Hilbish job. +## Object properties +||| +|----|----| +|cmd|The user entered command string for the job.| +|running|Whether the job is running or not.| +|id|The ID of the job in the job table| +|pid|The Process ID| +|exitCode|The last exit code of the job.| +|stdout|The standard output of the job. This just means the normal logs of the process.| +|stderr|The standard error stream of the process. This (usually) includes error messages of the job.| + + +### Methods +#### background() +Puts a job in the background. This acts the same as initially running a job. + +#### foreground() +Puts a job in the foreground. This will cause it to run like it was +executed normally and wait for it to complete. + +#### start() +Starts running the job. + +#### stop() +Stops the job from running. + diff --git a/docs/api/hilbish/hilbish.os.md b/docs/api/hilbish/hilbish.os.md new file mode 100644 index 0000000..13b56b0 --- /dev/null +++ b/docs/api/hilbish/hilbish.os.md @@ -0,0 +1,20 @@ +--- +title: Module hilbish.os +description: operating system info +layout: doc +menu: + docs: + parent: "API" +--- + +## Introduction +Provides simple text information properties about the current operating system. +This mainly includes the name and version. + +## Static module fields +||| +|----|----| +|family|Family name of the current OS| +|name|Pretty name of the current OS| +|version|Version of the current OS| + diff --git a/nature/hilbish.lua b/nature/hilbish.lua index f2fee20..77d5511 100644 --- a/nature/hilbish.lua +++ b/nature/hilbish.lua @@ -11,7 +11,7 @@ hilbish.snail = snail.new() --- streams of the command with the table keys `out`, `err`, and `input` respectively. --- As a boolean, it specifies whether the command should use standard output or return its output streams. --- #example ---- This code is the same as `ls -l | wc -l` +--- -- This code is the same as `ls -l | wc -l` --- local fs = require 'fs' --- local pr, pw = fs.pipe() --- hilbish.run('ls -l', {