Skip to content

Commit

Permalink
Merge branch 'master' into unstable-env-var
Browse files Browse the repository at this point in the history
  • Loading branch information
neunenak authored Aug 8, 2023
2 parents 867aa20 + 63ed00f commit 180d661
Show file tree
Hide file tree
Showing 11 changed files with 305 additions and 153 deletions.
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ heck = "0.4.0"
lexiclean = "0.0.1"
libc = "0.2.0"
log = "0.4.4"
num_cpus = "1.15.0"
regex = "1.5.4"
serde = { version = "1.0.130", features = ["derive", "rc"] }
serde_json = "1.0.68"
Expand Down
266 changes: 136 additions & 130 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,134 +113,140 @@ You can also set the shell using command-line arguments. For example, to use Pow
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://forge.rust-lang.org/release/platform-support.html">Various</a></td>
<td><a href="https://www.rust-lang.org">Cargo</a></td>
<td><a href="https://crates.io/crates/just">just</a></td>
<td><code>cargo install just</code></td>
</tr>
<tr>
<td><a href="https://en.wikipedia.org/wiki/Microsoft_Windows">Microsoft Windows</a></td>
<td><a href="https://scoop.sh">Scoop</a></td>
<td><a href="https://github.com/ScoopInstaller/Main/blob/master/bucket/just.json">just</a></td>
<td><code>scoop install just</code></td>
</tr>
<tr>
<td><a href="https://docs.brew.sh/Installation">Various</a></td>
<td><a href="https://brew.sh">Homebrew</a></td>
<td><a href="https://formulae.brew.sh/formula/just">just</a></td>
<td><code>brew install just</code></td>
</tr>
<tr>
<td><a href="https://en.wikipedia.org/wiki/MacOS">macOS</a></td>
<td><a href="https://www.macports.org">MacPorts</a></td>
<td><a href="https://ports.macports.org/port/just/summary">just</a></td>
<td><code>port install just</code></td>
</tr>
<tr>
<td><a href="https://www.archlinux.org">Arch Linux</a></td>
<td><a href="https://wiki.archlinux.org/title/Pacman">pacman</a></td>
<td><a href="https://archlinux.org/packages/community/x86_64/just/">just</a></td>
<td><code>pacman -S just</code></td>
</tr>
<tr>
<td><a href="https://nixos.org/download.html#download-nix">Various</a></td>
<td><a href="https://nixos.org/nix/">Nix</a></td>
<td><a href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/just/default.nix">just</a></td>
<td><code>nix-env -iA nixpkgs.just</code></td>
</tr>
<tr>
<td><a href="https://nixos.org/nixos/">NixOS</a></td>
<td><a href="https://nixos.org/nix/">Nix</a></td>
<td><a href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/just/default.nix">just</a></td>
<td><code>nix-env -iA nixos.just</code></td>
</tr>
<tr>
<td><a href="https://getsol.us">Solus</a></td>
<td><a href="https://getsol.us/articles/package-management/basics/en">eopkg</a></td>
<td><a href="https://dev.getsol.us/source/just/">just</a></td>
<td><code>eopkg install just</code></td>
</tr>
<tr>
<td><a href="https://voidlinux.org">Void Linux</a></td>
<td><a href="https://wiki.voidlinux.org/XBPS">XBPS</a></td>
<td><a href="https://github.com/void-linux/void-packages/blob/master/srcpkgs/just/template">just</a></td>
<td><code>xbps-install -S just</code></td>
</tr>
<tr>
<td><a href="https://www.freebsd.org">FreeBSD</a></td>
<td><a href="https://www.freebsd.org/doc/handbook/pkgng-intro.html">pkg</a></td>
<td><a href="https://www.freshports.org/deskutils/just/">just</a></td>
<td><code>pkg install just</code></td>
</tr>
<tr>
<td><a href="https://alpinelinux.org">Alpine Linux</a></td>
<td><a href="https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management">apk-tools</a></td>
<td><a href="https://pkgs.alpinelinux.org/package/edge/community/x86_64/just">just</a></td>
<td><code>apk add just</code></td>
</tr>
<tr>
<td><a href="https://getfedora.org">Fedora Linux</a></td>
<td><a href="https://dnf.readthedocs.io/en/latest/">DNF</a></td>
<td><a href="https://src.fedoraproject.org/rpms/rust-just">just</a></td>
<td><code>dnf install just</code></td>
</tr>
<tr>
<td><a href="https://www.gentoo.org">Gentoo Linux</a></td>
<td><a href="https://wiki.gentoo.org/wiki/Portage">Portage</a></td>
<td><a href="https://github.com/gentoo-mirror/dm9pZCAq/tree/master/sys-devel/just">dm9pZCAq/sys-devel/just</a></td>
<td>
<code>eselect repository enable dm9pZCAq</code><br>
<code>emerge --sync dm9pZCAq</code><br>
<code>emerge sys-devel/just</code>
</td>
</tr>
<tr>
<td><a href="https://docs.conda.io/en/latest/miniconda.html#system-requirements">Various</a></td>
<td><a href="https://docs.conda.io/projects/conda/en/latest/index.html">Conda</a></td>
<td><a href="https://anaconda.org/conda-forge/just">just</a></td>
<td><code>conda install -c conda-forge just</code></td>
</tr>
<tr>
<td><a href="https://en.wikipedia.org/wiki/Microsoft_Windows">Microsoft Windows</a></td>
<td><a href="https://chocolatey.org">Chocolatey</a></td>
<td><a href="https://github.com/michidk/just-choco">just</a></td>
<td><code>choco install just</code></td>
</tr>
<tr>
<td><a href="https://snapcraft.io/docs/installing-snapd">Various</a></td>
<td><a href="https://snapcraft.io">Snap</a></td>
<td><a href="https://snapcraft.io/just">just</a></td>
<td><code>snap install --edge --classic just</code></td>
</tr>
<tr>
<td><a href="https://github.com/casey/just/releases">Various</a></td>
<td><a href="https://asdf-vm.com">asdf</a></td>
<td><a href="https://github.com/olofvndrhr/asdf-just">just</a></td>
<td>
<code>asdf plugin add just</code><br>
<code>asdf install just &lt;version&gt;</code>
</td>
</tr>
<tr>
<td><a href="https://debian.org">Debian</a> and <a href="https://ubuntu.com">Ubuntu</a> derivatives</td>
<td><a href="https://mpr.makedeb.org">MPR</a></td>
<td><a href="https://mpr.makedeb.org/packages/just">just</a></td>
<td>
<code>git clone 'https://mpr.makedeb.org/just'</code><br>
<code>cd just</code><br>
<code>makedeb -si</code>
</td>
</tr>
<tr>
<td><a href="https://debian.org">Debian</a> and <a href="https://ubuntu.com">Ubuntu</a> derivatives</td>
<td><a href="https://docs.makedeb.org/prebuilt-mpr">Prebuilt-MPR</a></td>
<td><a href="https://mpr.makedeb.org/packages/just">just</a></td>
<td>
<sup><b>You must have the <a href="https://docs.makedeb.org/prebuilt-mpr/getting-started/#setting-up-the-repository">Prebuilt-MPR set up</a> on your system in order to run this command.</b></sup><br>
<code>sudo apt install just</code>
</td>
</tr>
<tr>
<td><a href="https://forge.rust-lang.org/release/platform-support.html">Various</a></td>
<td><a href="https://www.rust-lang.org">Cargo</a></td>
<td><a href="https://crates.io/crates/just">just</a></td>
<td><code>cargo install just</code></td>
</tr>
<tr>
<td><a href="https://en.wikipedia.org/wiki/Microsoft_Windows">Microsoft Windows</a></td>
<td><a href="https://scoop.sh">Scoop</a></td>
<td><a href="https://github.com/ScoopInstaller/Main/blob/master/bucket/just.json">just</a></td>
<td><code>scoop install just</code></td>
</tr>
<tr>
<td><a href="https://docs.brew.sh/Installation">Various</a></td>
<td><a href="https://brew.sh">Homebrew</a></td>
<td><a href="https://formulae.brew.sh/formula/just">just</a></td>
<td><code>brew install just</code></td>
</tr>
<tr>
<td><a href="https://en.wikipedia.org/wiki/MacOS">macOS</a></td>
<td><a href="https://www.macports.org">MacPorts</a></td>
<td><a href="https://ports.macports.org/port/just/summary">just</a></td>
<td><code>port install just</code></td>
</tr>
<tr>
<td><a href="https://www.archlinux.org">Arch Linux</a></td>
<td><a href="https://wiki.archlinux.org/title/Pacman">pacman</a></td>
<td><a href="https://archlinux.org/packages/community/x86_64/just/">just</a></td>
<td><code>pacman -S just</code></td>
</tr>
<tr>
<td><a href="https://nixos.org/download.html#download-nix">Various</a></td>
<td><a href="https://nixos.org/nix/">Nix</a></td>
<td><a href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/just/default.nix">just</a></td>
<td><code>nix-env -iA nixpkgs.just</code></td>
</tr>
<tr>
<td><a href="https://nixos.org/nixos/">NixOS</a></td>
<td><a href="https://nixos.org/nix/">Nix</a></td>
<td><a href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/just/default.nix">just</a></td>
<td><code>nix-env -iA nixos.just</code></td>
</tr>
<tr>
<td><a href="https://getsol.us">Solus</a></td>
<td><a href="https://getsol.us/articles/package-management/basics/en">eopkg</a></td>
<td><a href="https://dev.getsol.us/source/just/">just</a></td>
<td><code>eopkg install just</code></td>
</tr>
<tr>
<td><a href="https://voidlinux.org">Void Linux</a></td>
<td><a href="https://wiki.voidlinux.org/XBPS">XBPS</a></td>
<td><a href="https://github.com/void-linux/void-packages/blob/master/srcpkgs/just/template">just</a></td>
<td><code>xbps-install -S just</code></td>
</tr>
<tr>
<td><a href="https://www.freebsd.org">FreeBSD</a></td>
<td><a href="https://www.freebsd.org/doc/handbook/pkgng-intro.html">pkg</a></td>
<td><a href="https://www.freshports.org/deskutils/just/">just</a></td>
<td><code>pkg install just</code></td>
</tr>
<tr>
<td><a href="https://alpinelinux.org">Alpine Linux</a></td>
<td><a href="https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management">apk-tools</a></td>
<td><a href="https://pkgs.alpinelinux.org/package/edge/community/x86_64/just">just</a></td>
<td><code>apk add just</code></td>
</tr>
<tr>
<td><a href="https://getfedora.org">Fedora Linux</a></td>
<td><a href="https://dnf.readthedocs.io/en/latest/">DNF</a></td>
<td><a href="https://src.fedoraproject.org/rpms/rust-just">just</a></td>
<td><code>dnf install just</code></td>
</tr>
<tr>
<td><a href="https://www.gentoo.org">Gentoo Linux</a></td>
<td><a href="https://wiki.gentoo.org/wiki/Portage">Portage</a></td>
<td><a href="https://github.com/gentoo-mirror/dm9pZCAq/tree/master/sys-devel/just">dm9pZCAq/sys-devel/just</a></td>
<td>
<code>eselect repository enable dm9pZCAq</code><br>
<code>emerge --sync dm9pZCAq</code><br>
<code>emerge sys-devel/just</code>
</td>
</tr>
<tr>
<td><a href="https://docs.conda.io/en/latest/miniconda.html#system-requirements">Various</a></td>
<td><a href="https://docs.conda.io/projects/conda/en/latest/index.html">Conda</a></td>
<td><a href="https://anaconda.org/conda-forge/just">just</a></td>
<td><code>conda install -c conda-forge just</code></td>
</tr>
<tr>
<td><a href="https://en.wikipedia.org/wiki/Microsoft_Windows">Microsoft Windows</a></td>
<td><a href="https://chocolatey.org">Chocolatey</a></td>
<td><a href="https://github.com/michidk/just-choco">just</a></td>
<td><code>choco install just</code></td>
</tr>
<tr>
<td><a href="https://snapcraft.io/docs/installing-snapd">Various</a></td>
<td><a href="https://snapcraft.io">Snap</a></td>
<td><a href="https://snapcraft.io/just">just</a></td>
<td><code>snap install --edge --classic just</code></td>
</tr>
<tr>
<td><a href="https://github.com/casey/just/releases">Various</a></td>
<td><a href="https://asdf-vm.com">asdf</a></td>
<td><a href="https://github.com/olofvndrhr/asdf-just">just</a></td>
<td>
<code>asdf plugin add just</code><br>
<code>asdf install just &lt;version&gt;</code>
</td>
</tr>
<tr>
<td><a href="https://debian.org">Debian</a> and <a href="https://ubuntu.com">Ubuntu</a> derivatives</td>
<td><a href="https://mpr.makedeb.org">MPR</a></td>
<td><a href="https://mpr.makedeb.org/packages/just">just</a></td>
<td>
<code>git clone 'https://mpr.makedeb.org/just'</code><br>
<code>cd just</code><br>
<code>makedeb -si</code>
</td>
</tr>
<tr>
<td><a href="https://debian.org">Debian</a> and <a href="https://ubuntu.com">Ubuntu</a> derivatives</td>
<td><a href="https://docs.makedeb.org/prebuilt-mpr">Prebuilt-MPR</a></td>
<td><a href="https://mpr.makedeb.org/packages/just">just</a></td>
<td>
<sup><b>You must have the <a href="https://docs.makedeb.org/prebuilt-mpr/getting-started/#setting-up-the-repository">Prebuilt-MPR set up</a> on your system in order to run this command.</b></sup><br>
<code>sudo apt install just</code>
</td>
</tr>
<tr>
<td><a href="https://en.wikipedia.org/wiki/Microsoft_Windows">Microsoft Windows</a></td>
<td><a href="https://learn.microsoft.com/en-us/windows/package-manager/">Windows Package Manager</a></td>
<td><a href="https://github.com/microsoft/winget-pkgs/tree/master/manifests/c/Casey/Just">Casey/Just</a></td>
<td><code>winget install --id Casey.Just --exact</code></td>
</tr>
</tbody>
</table>

Expand Down Expand Up @@ -1075,6 +1081,7 @@ Done!
#### System Information

- `arch()` — Instruction set architecture. Possible values are: `"aarch64"`, `"arm"`, `"asmjs"`, `"hexagon"`, `"mips"`, `"msp430"`, `"powerpc"`, `"powerpc64"`, `"s390x"`, `"sparc"`, `"wasm32"`, `"x86"`, `"x86_64"`, and `"xcore"`.
- `num_cpus()` - Number of logical CPUs.
- `os()` — Operating system. Possible values are: `"android"`, `"bitrig"`, `"dragonfly"`, `"emscripten"`, `"freebsd"`, `"haiku"`, `"ios"`, `"linux"`, `"macos"`, `"netbsd"`, `"openbsd"`, `"solaris"`, and `"windows"`.
- `os_family()` — Operating system family; possible values are: `"unix"` and `"windows"`.

Expand Down Expand Up @@ -2315,8 +2322,7 @@ $ just --dump > formatted-justfile
```

The `--dump` command can be used with `--dump-format json` to print a JSON
representation of a `justfile`. The JSON format is currently unstable, so the
`--unstable` flag is required.
representation of a `justfile`.

### Fallback to parent `justfile`s

Expand Down
6 changes: 6 additions & 0 deletions src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub(crate) fn get(name: &str) -> Option<Function> {
"kebabcase" => Unary(kebabcase),
"lowercamelcase" => Unary(lowercamelcase),
"lowercase" => Unary(lowercase),
"num_cpus" => Nullary(num_cpus),
"os" => Nullary(os),
"os_family" => Nullary(os_family),
"parent_directory" => Unary(parent_directory),
Expand Down Expand Up @@ -270,6 +271,11 @@ fn lowercase(_context: &FunctionContext, s: &str) -> Result<String, String> {
Ok(s.to_lowercase())
}

fn num_cpus(_context: &FunctionContext) -> Result<String, String> {
let num = num_cpus::get();
Ok(num.to_string())
}

fn os(_context: &FunctionContext) -> Result<String, String> {
Ok(target::os().to_owned())
}
Expand Down
4 changes: 2 additions & 2 deletions src/justfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -930,11 +930,11 @@ c := a + b + a + b",
x := arch()
a:
{{os()}} {{os_family()}}",
{{os()}} {{os_family()}} {{num_cpus()}}",
"x := arch()
a:
{{ os() }} {{ os_family() }}",
{{ os() }} {{ os_family() }} {{ num_cpus() }}",
}

test! {
Expand Down
Loading

0 comments on commit 180d661

Please sign in to comment.