Browse Source

Documented the command line interface

tags/v1.0.0
Cédric Belin 4 months ago
parent
commit
953ffd93f5
5 changed files with 112 additions and 8 deletions
  1. +1
    -1
      README.md
  2. +2
    -2
      doc/index.md
  3. +6
    -4
      doc/installation.md
  4. +100
    -0
      doc/usage/cli.md
  5. +3
    -1
      etc/mkdocs.yaml

+ 1
- 1
README.md View File

@@ -2,7 +2,7 @@
![Haxe](https://badgen.net/badge/haxe/%3E%3D4.1.0/green) ![Haxelib](https://badgen.net/haxelib/v/which) ![Downloads](https://badgen.net/haxelib/d/which)
![Node.js](https://badgen.net/npm/node/@cedx/which.hx) ![npm](https://badgen.net/npm/v/@cedx/which.hx) ![Types](https://badgen.net/npm/types/@cedx/which.hx) ![Downloads](https://badgen.net/npm/dt/@cedx/which.hx)
![PHP](https://badgen.net/packagist/php/cedx/which.hx) ![Packagist](https://badgen.net/packagist/v/cedx/which.hx) ![Downloads](https://badgen.net/packagist/dt/cedx/which.hx)
![License](https://badgen.net/badge/license/MIT/blue) ![Coverage](https://badgen.net/coveralls/c/github/cedx/which.hx) ![Build](https://badgen.net/github/checks/cedx/which.hx)
![License](https://badgen.net/badge/license/MIT/blue) ![Coverage](https://badgen.net/coveralls/c/github/cedx/which.hx) ![Build](https://badgen.net/github/checks/cedx/which.hx/main)

Find the instances of an executable in the system path,
in [Haxe](https://haxe.org), [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) and [PHP](https://www.php.net).


+ 2
- 2
doc/index.md View File

@@ -2,13 +2,13 @@
![Haxe](https://badgen.net/badge/haxe/%3E%3D4.1.0/green) ![Haxelib](https://badgen.net/haxelib/v/which) ![Downloads](https://badgen.net/haxelib/d/which)
![Node.js](https://badgen.net/npm/node/@cedx/which.hx) ![npm](https://badgen.net/npm/v/@cedx/which.hx) ![Types](https://badgen.net/npm/types/@cedx/which.hx) ![Downloads](https://badgen.net/npm/dt/@cedx/which.hx)
![PHP](https://badgen.net/packagist/php/cedx/which.hx) ![Packagist](https://badgen.net/packagist/v/cedx/which.hx) ![Downloads](https://badgen.net/packagist/dt/cedx/which.hx)
![License](https://badgen.net/badge/license/MIT/blue) ![Coverage](https://badgen.net/coveralls/c/github/cedx/which.hx) ![Build](https://badgen.net/github/checks/cedx/which.hx)
![License](https://badgen.net/badge/license/MIT/blue) ![Coverage](https://badgen.net/coveralls/c/github/cedx/which.hx) ![Build](https://badgen.net/github/checks/cedx/which.hx/main)

Find the instances of an executable in the system path,
in [Haxe](https://haxe.org), [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) and [PHP](https://www.php.net).

## Quick start
Install the latest version of **Which.hx** with [npm](https://www.npmjs.com):
Install the latest version of **Which.hx** with your favorite package manager:

=== "Haxe"
:::shell


+ 6
- 4
doc/installation.md View File

@@ -9,7 +9,7 @@ You can verify if you're already good to go with the following commands:
=== "Haxe"
:::shell
haxe --version
# 4.1.1
# 4.1.2

haxelib version
# 4.0.2
@@ -25,7 +25,7 @@ You can verify if you're already good to go with the following commands:
=== "PHP"
:::shell
php --version
# PHP 7.4.6 (cli) (built: May 12 2020 11:38:52) ( NTS Visual C++ 2017 x64 )
# PHP 7.4.7 (cli) (built: Jun 9 2020 13:34:30) ( NTS Visual C++ 2017 x64 )

composer --version
# Composer version 1.10.7 2020-06-03 10:03:56
@@ -45,7 +45,8 @@ You can verify if you're already good to go with the following commands:
Now in your [Haxe](https://haxe.org) code, you can use:

:::haxe
using which.Tools;
import which.FinderException;
import which.FinderTools;

=== "JavaScript"
From a command prompt, run:
@@ -72,4 +73,5 @@ You can verify if you're already good to go with the following commands:

:::php
<?php
use function which\{which};
use function which\which;
use which\FinderException;

+ 100
- 0
doc/usage/cli.md View File

@@ -0,0 +1,100 @@
---
path: src/branch/main
source: src/which/Program.hx
---

# Command line interface
Start by installing the `which` executable globally with your package manager.

=== "Haxe"
From a command prompt, run:

:::shell
haxelib --global install which

Now in your terminal, you can use:

:::shell
haxelib run which --version

=== "JavaScript"
From a command prompt, run:

:::shell
npm install --global @cedx/which.hx

Now in your terminal, you can use:

:::shell
which --version

!!! tip
Consider adding the [`npm install --global`](https://docs.npmjs.com/files/folders) executables directory to your system path.

=== "PHP"
From a command prompt, run:

:::shell
composer global require cedx/which.hx

Now in your terminal, you can use:

:::shell
composer global exec which --version

!!! tip
Consider adding the [`composer global`](https://getcomposer.org/doc/03-cli.md#global) executables directory to your system path.

Then invoke it to find the instances of an executable command:

``` shell
$ which --help

Find the instances of an executable in the system path.

<command> : The name of the command to find.

Flags:
--all, -a : List all instances of executables found (instead of just the first one).
--help, -h : Output usage information.
--silent, -s : Silence the output, just return the exit code (0 if any executable is found, otherwise 1).
--version, -v : Output the version number.
```

For example:

=== "Haxe"
:::shell
haxelib run which haxe
# /usr/bin/haxe

haxelib run which --all haxe
# /usr/bin/haxe
# /usr/local/bin/haxe

haxelib run which --silent haxe
# Exit code 0 if "haxe" is found, otherwise 1

=== "JavaScript"
:::shell
which node
# /usr/bin/node

which --all node
# /usr/bin/node
# /usr/local/bin/node

which --silent node
# Exit code 0 if "node" is found, otherwise 1

=== "PHP"
:::shell
which php
# /usr/bin/php

which --all php
# /usr/bin/php
# /usr/local/bin/php

which --silent php
# Exit code 0 if "php" is found, otherwise 1

+ 3
- 1
etc/mkdocs.yaml View File

@@ -40,7 +40,9 @@ markdown_extensions:
nav:
- Overview: index.md
- Installation: installation.md
- Usage: usage.md
- Usage:
- Programming interface: usage/api.md
- Command line interface: usage/cli.md
- About:
- License: about/license.md
- See also: about/see_also.md


Loading…
Cancel
Save