Introduce "binary" scripts for all native commands #116

Manually merged
FWDekker merged 5 commits from binaries into master 2020-03-22 13:16:12 +01:00
Owner

Fixes #114.

All "native" commands such as cd and mkdir are now stored as files in /bin. When a user invokes a command, josh will look for it in /bin, eval the contents of the appropriate file, and execute it. Similarly, the help command now dynamically finds the documentation of a command. Users can now also write their own commands, and if those are stored in directories other than /bin, the user must give a (relative or absolute) path instead of just a word. Either way, josh uses the new resolve function in Commands.

Commands have access to input and streams as before, but now also have a number of additional variables loaded into their namespace. This is done in the private interpretScript method in Commands. Variables include classes that should be available to commands, but also the important josh variable. This variable essentially contains the API for interacting with the shell. josh has references to the file system, environment, user list, and also has a number of useful utilities. This API can be extended easily if necessary.

All basic commands are now stored as strings in Commands.ts. This means that the IDE does not give suggestions or highlight errors. Also note that they are written in JavaScript instead of TypeScript. Because of these limitations, the commands have (finally) been tested extensively where possible. Some commands, such as open and poweroff have not been tested because they would require some sort of dependency injection, which is not suitable for this PR.

Fixes #114. All "native" commands such as `cd` and `mkdir` are now stored as files in `/bin`. When a user invokes a command, josh will look for it in `/bin`, `eval` the contents of the appropriate file, and execute it. Similarly, the `help` command now dynamically finds the documentation of a command. Users can now also write their own commands, and if those are stored in directories other than `/bin`, the user must give a (relative or absolute) path instead of just a word. Either way, josh uses the new `resolve` function in `Commands`. Commands have access to `input` and `streams` as before, but now also have a number of additional variables loaded into their namespace. This is done in the private `interpretScript` method in `Commands`. Variables include classes that should be available to commands, but also the important `josh` variable. This variable essentially contains the API for interacting with the shell. `josh` has references to the file system, environment, user list, and also has a number of useful utilities. This API can be extended easily if necessary. All basic commands are now stored as strings in `Commands.ts`. This means that the IDE does not give suggestions or highlight errors. Also note that they are written in JavaScript instead of TypeScript. Because of these limitations, the commands have (finally) been tested extensively where possible. Some commands, such as `open` and `poweroff` have not been tested because they would require some sort of dependency injection, which is not suitable for this PR.
FWDekker added this to the v1.0.0 milestone 2020-03-22 13:01:41 +01:00
FWDekker added the
feature
label 2020-03-22 13:01:41 +01:00
FWDekker self-assigned this 2020-03-22 13:01:41 +01:00
FWDekker closed this pull request 2020-03-22 13:16:12 +01:00
FWDekker deleted branch binaries 2020-03-22 13:17:28 +01:00
Sign in to join this conversation.
No description provided.