Module hilbish.jobs

background job management

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) -> @JobGet a job object via its ID.
last() -> @JobReturns 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
1hilbish.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

cmdThe user entered command string for the job.
runningWhether the job is running or not.
idThe ID of the job in the job table
pidThe Process ID
exitCodeThe last exit code of the job.
stdoutThe standard output of the job. This just means the normal logs of the process.
stderrThe 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.