diff --git a/docs/api/commander/index.html b/docs/api/commander/index.html index 4f881cf..b599332 100644 --- a/docs/api/commander/index.html +++ b/docs/api/commander/index.html @@ -3,7 +3,24 @@ Hilbish

Module commander

library for custom commands

Introduction -

Commander is a library for writing custom commands in Lua.

Functions +

Commander is a library for writing custom commands in Lua. +In order to make it easier to write commands for Hilbish, +not require separate scripts and to be able to use in a config, +the Commander library exists. This is like a very simple wrapper +that works with Hilbish for writing commands. Example:

local commander = require 'commander'
+
+commander.register('hello', function(args, sinks)
+	sinks.out:writeln 'Hello world!'
+end)
+

In this example, a command with the name of hello is created +that will print Hello world! to output. One question you may +have is: What is the sinks parameter?

A sink is a writable/readable pipe, or you can imagine a Lua +file. It’s used in this case to write to the proper output, +incase a user either pipes to another command or redirects somewhere else.

So, the sinks parameter is a table containing 3 sinks: +in, out, and err.

  • in is the standard input. You can read from this sink +to get user input. (This is currently unimplemented.)
  • out is standard output. This is usually where text meant for +output should go.
  • err is standard error. This sink is for writing errors, as the +name would suggest.

A sink has 2 methods:

  • write(str) will write to the sink.
  • writeln(str) will write to the sink with a newline at the end.

Functions

deregister(name)

Deregisters any command registered with name

register(name, cb)

Register a command with name that runs cb when ran

\ No newline at end of file diff --git a/docs/api/index.xml b/docs/api/index.xml index dd45cf8..2ca3d48 100644 --- a/docs/api/index.xml +++ b/docs/api/index.xml @@ -1,7 +1,6 @@ API on Hilbishhttps://rosettea.github.io/Hilbish/docs/api/Recent content in API on HilbishHugo -- gohugo.ioen-usModule baithttps://rosettea.github.io/Hilbish/docs/api/bait/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/docs/api/bait/Introduction Bait is the event emitter for Hilbish. Why name it bait? Why not. It throws hooks that you can catch. This is what you will use if you want to listen in on hooks to know when certain things have happened, like when you’ve changed directory, a command has failed, etc. To find all available hooks thrown by Hilbish, see doc hooks. -Functions catch(name, cb) Catches a hook with name.Module commanderhttps://rosettea.github.io/Hilbish/docs/api/commander/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/docs/api/commander/Introduction Commander is a library for writing custom commands in Lua. -Functions deregister(name) Deregisters any command registered with name -register(name, cb) Register a command with name that runs cb when ranModule fshttps://rosettea.github.io/Hilbish/docs/api/fs/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/docs/api/fs/Introduction The fs module provides easy and simple access to filesystem functions and other things, and acts an addition to the Lua standard library’s I/O and filesystem functions. +Functions catch(name, cb) Catches a hook with name.Module commanderhttps://rosettea.github.io/Hilbish/docs/api/commander/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/docs/api/commander/Introduction Commander is a library for writing custom commands in Lua. In order to make it easier to write commands for Hilbish, not require separate scripts and to be able to use in a config, the Commander library exists. This is like a very simple wrapper that works with Hilbish for writing commands. Example: +local commander = require 'commander' commander.register('hello', function(args, sinks) sinks.out:writeln 'Hello world!' end) In this example, a command with the name of hello is created that will print Hello world!Module fshttps://rosettea.github.io/Hilbish/docs/api/fs/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/docs/api/fs/Introduction The fs module provides easy and simple access to filesystem functions and other things, and acts an addition to the Lua standard library’s I/O and filesystem functions. Functions abs(path) Gives an absolute version of path. basename(path) Gives the basename of path. For the rules, see Go’s filepath.Base cd(dir) Changes directory to dir diff --git a/index.xml b/index.xml index 02784f5..c725a38 100644 --- a/index.xml +++ b/index.xml @@ -29,9 +29,8 @@ Interface fields family: Family name of the current OS name: Pretty name of the Functions setMode(cb) This is the same as the hilbish.runnerMode function. It takes a callback, which will be used to execute all interactive input.Interface hilbish.timershttps://rosettea.github.io/Hilbish/docs/api/hilbish/hilbish.timers/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/docs/api/hilbish/hilbish.timers/Introduction If you ever want to run a piece of code on a timed interval, or want to wait a few seconds, you don’t have to rely on timing tricks, as Hilbish has a timer API to set intervals and timeouts. These are the simple functions hilbish.interval and hilbish.timeout (doc accessible with doc hilbish). But if you want slightly more control over them, there is the hilbish.timers interface. It allows you to get a timer via ID and control them.Interface hilbish.userDirhttps://rosettea.github.io/Hilbish/docs/api/hilbish/hilbish.userdir/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/docs/api/hilbish/hilbish.userdir/ Introduction This interface just contains properties to know about certain user directories. It is equivalent to XDG on Linux and gets the user’s preferred directories for configs and data. Interface fields config: The user’s config directory data: The user’s directory for program dataModule baithttps://rosettea.github.io/Hilbish/docs/api/bait/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/docs/api/bait/Introduction Bait is the event emitter for Hilbish. Why name it bait? Why not. It throws hooks that you can catch. This is what you will use if you want to listen in on hooks to know when certain things have happened, like when you’ve changed directory, a command has failed, etc. To find all available hooks thrown by Hilbish, see doc hooks. -Functions catch(name, cb) Catches a hook with name.Module commanderhttps://rosettea.github.io/Hilbish/docs/api/commander/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/docs/api/commander/Introduction Commander is a library for writing custom commands in Lua. -Functions deregister(name) Deregisters any command registered with name -register(name, cb) Register a command with name that runs cb when ranModule fshttps://rosettea.github.io/Hilbish/docs/api/fs/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/docs/api/fs/Introduction The fs module provides easy and simple access to filesystem functions and other things, and acts an addition to the Lua standard library’s I/O and filesystem functions. +Functions catch(name, cb) Catches a hook with name.Module commanderhttps://rosettea.github.io/Hilbish/docs/api/commander/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/docs/api/commander/Introduction Commander is a library for writing custom commands in Lua. In order to make it easier to write commands for Hilbish, not require separate scripts and to be able to use in a config, the Commander library exists. This is like a very simple wrapper that works with Hilbish for writing commands. Example: +local commander = require 'commander' commander.register('hello', function(args, sinks) sinks.out:writeln 'Hello world!' end) In this example, a command with the name of hello is created that will print Hello world!Module fshttps://rosettea.github.io/Hilbish/docs/api/fs/Mon, 01 Jan 0001 00:00:00 +0000https://rosettea.github.io/Hilbish/docs/api/fs/Introduction The fs module provides easy and simple access to filesystem functions and other things, and acts an addition to the Lua standard library’s I/O and filesystem functions. Functions abs(path) Gives an absolute version of path. basename(path) Gives the basename of path. For the rules, see Go’s filepath.Base cd(dir) Changes directory to dir