mirror of
https://github.com/tealdeer-rs/tealdeer.git
synced 2026-08-09 09:49:10 +02:00
Add BSD platform support and update workflows (#354)
This commit is contained in:
parent
c8f2408373
commit
ee6d2418f1
11 changed files with 58 additions and 28 deletions
6
.github/dependabot.yml
vendored
Normal file
6
.github/dependabot.yml
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "monthly"
|
||||
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
|
|
@ -17,7 +17,7 @@ jobs:
|
|||
toolchain: [stable, 1.64.0]
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: ${{ matrix.toolchain }}
|
||||
|
|
@ -32,7 +32,7 @@ jobs:
|
|||
name: run clippy lints
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: stable
|
||||
|
|
@ -44,7 +44,7 @@ jobs:
|
|||
name: run rustfmt
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: stable
|
||||
|
|
@ -56,7 +56,7 @@ jobs:
|
|||
name: build docs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup mdBook
|
||||
uses: peaceiris/actions-mdbook@v1
|
||||
with:
|
||||
|
|
|
|||
2
.github/workflows/gh-pages.yml
vendored
2
.github/workflows/gh-pages.yml
vendored
|
|
@ -9,7 +9,7 @@ jobs:
|
|||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup mdBook
|
||||
uses: peaceiris/actions-mdbook@v1
|
||||
|
|
|
|||
22
.github/workflows/release.yml
vendored
22
.github/workflows/release.yml
vendored
|
|
@ -7,7 +7,7 @@ jobs:
|
|||
create-release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Create release for tag
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
|
|
@ -23,7 +23,7 @@ jobs:
|
|||
matrix:
|
||||
target: ["bash", "fish", "zsh"]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Upload completion
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
|
|
@ -39,7 +39,7 @@ jobs:
|
|||
matrix:
|
||||
target: ["MIT", "APACHE"]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Upload license
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
|
|
@ -65,14 +65,14 @@ jobs:
|
|||
- arch: "arm"
|
||||
libc: "musleabihf"
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Pull Docker image
|
||||
run: docker pull messense/rust-musl-cross:${{ matrix.arch }}-${{ matrix.libc }}
|
||||
- name: Build in Docker
|
||||
run: docker run --rm -i -v "$(pwd)":/home/rust/src messense/rust-musl-cross:${{ matrix.arch }}-${{ matrix.libc }} cargo build --release
|
||||
- name: Strip binary
|
||||
run: docker run --rm -i -v "$(pwd)":/home/rust/src messense/rust-musl-cross:${{ matrix.arch }}-${{ matrix.libc }} musl-strip -s /home/rust/src/target/${{ matrix.arch }}-unknown-linux-${{ matrix.libc }}/release/tldr
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: "tealdeer-linux-${{ matrix.arch }}-${{ matrix.libc }}"
|
||||
path: "target/${{ matrix.arch }}-unknown-linux-${{ matrix.libc }}/release/tldr"
|
||||
|
|
@ -80,14 +80,14 @@ jobs:
|
|||
build-macos:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup toolchain
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: stable
|
||||
- name: Build
|
||||
run: cargo build --release --target x86_64-apple-darwin --no-default-features --features webpki-roots
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: "tealdeer-macos-x86_64"
|
||||
path: "target/x86_64-apple-darwin/release/tldr"
|
||||
|
|
@ -95,14 +95,14 @@ jobs:
|
|||
build-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup toolchain
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: stable
|
||||
- name: Build
|
||||
run: cargo build --release --target x86_64-pc-windows-msvc
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: "tealdeer-windows-x86_64-msvc"
|
||||
path: "target/x86_64-pc-windows-msvc/release/tldr.exe"
|
||||
|
|
@ -126,8 +126,8 @@ jobs:
|
|||
- macos-x86_64
|
||||
- windows-x86_64-msvc
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/download-artifact@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/download-artifact@v4
|
||||
- name: Upload binary
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ _tealdeer()
|
|||
return
|
||||
;;
|
||||
-p|--platform)
|
||||
COMPREPLY=( $(compgen -W 'linux macos sunos windows android' -- "${cur}") )
|
||||
COMPREPLY=( $(compgen -W 'linux macos sunos windows android freebsd netbsd openbsd' -- "${cur}") )
|
||||
return
|
||||
;;
|
||||
--color)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ complete -c tldr -s h -l help -d 'Print the help message.' -f
|
|||
complete -c tldr -s v -l version -d 'Show version information.' -f
|
||||
complete -c tldr -s l -l list -d 'List all commands in the cache.' -f
|
||||
complete -c tldr -s f -l render -d 'Render a specific markdown file.' -r
|
||||
complete -c tldr -s p -l platform -d 'Override the operating system.' -xa 'linux macos sunos windows android'
|
||||
complete -c tldr -s p -l platform -d 'Override the operating system.' -xa 'linux macos sunos windows android freebsd netbsd openbsd'
|
||||
complete -c tldr -s L -l language -d 'Override the language' -x
|
||||
complete -c tldr -s u -l update -d 'Update the local cache.' -f
|
||||
complete -c tldr -l no-auto-update -d 'If auto update is configured, disable it for this run.' -f
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ _tealdeer() {
|
|||
sunos
|
||||
windows
|
||||
android
|
||||
freebsd
|
||||
netbsd
|
||||
openbsd
|
||||
))'
|
||||
"($I -L --language)"{-L,--language}"[Override the language settings]:lang"
|
||||
"($I -u --update)"{-u,--update}"[Update the local cache]"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ OPTIONS:
|
|||
-l, --list List all commands in the cache
|
||||
-f, --render <FILE> Render a specific markdown file
|
||||
-p, --platform <PLATFORMS> Override the operating system [possible values: linux, macos,
|
||||
windows, sunos, osx, android]
|
||||
windows, sunos, osx, android, freebsd, netbsd, openbsd]
|
||||
-L, --language <LANGUAGE> Override the language
|
||||
-u, --update Update the local cache
|
||||
--no-auto-update If auto update is configured, disable it for this run
|
||||
|
|
|
|||
|
|
@ -218,6 +218,9 @@ impl Cache {
|
|||
PlatformType::SunOs => "sunos",
|
||||
PlatformType::Windows => "windows",
|
||||
PlatformType::Android => "android",
|
||||
PlatformType::FreeBsd => "freebsd",
|
||||
PlatformType::NetBsd => "netbsd",
|
||||
PlatformType::OpenBsd => "openbsd",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ pub(crate) struct Args {
|
|||
short = 'p',
|
||||
long = "platform",
|
||||
action = ArgAction::Append,
|
||||
possible_values = ["linux", "macos", "windows", "sunos", "osx", "android"],
|
||||
possible_values = ["linux", "macos", "windows", "sunos", "osx", "android", "freebsd", "netbsd", "openbsd"],
|
||||
)]
|
||||
pub platforms: Option<Vec<PlatformType>>,
|
||||
|
||||
|
|
|
|||
34
src/types.rs
34
src/types.rs
|
|
@ -14,6 +14,9 @@ pub enum PlatformType {
|
|||
SunOs,
|
||||
Windows,
|
||||
Android,
|
||||
FreeBsd,
|
||||
NetBsd,
|
||||
OpenBsd,
|
||||
}
|
||||
|
||||
impl fmt::Display for PlatformType {
|
||||
|
|
@ -24,6 +27,9 @@ impl fmt::Display for PlatformType {
|
|||
Self::SunOs => write!(f, "SunOS"),
|
||||
Self::Windows => write!(f, "Windows"),
|
||||
Self::Android => write!(f, "Android"),
|
||||
Self::FreeBsd => write!(f, "FreeBSD"),
|
||||
Self::NetBsd => write!(f, "NetBSD"),
|
||||
Self::OpenBsd => write!(f, "OpenBSD"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -38,8 +44,11 @@ impl str::FromStr for PlatformType {
|
|||
"sunos" => Ok(Self::SunOs),
|
||||
"windows" => Ok(Self::Windows),
|
||||
"android" => Ok(Self::Android),
|
||||
"freebsd" => Ok(Self::FreeBsd),
|
||||
"netbsd" => Ok(Self::NetBsd),
|
||||
"openbsd" => Ok(Self::OpenBsd),
|
||||
other => Err(anyhow!(
|
||||
"Unknown OS: {}. Possible values: linux, macos, osx, sunos, windows, android",
|
||||
"Unknown OS: {}. Possible values: linux, macos, osx, sunos, windows, android, freebsd, netbsd, openbsd",
|
||||
other
|
||||
)),
|
||||
}
|
||||
|
|
@ -52,13 +61,7 @@ impl PlatformType {
|
|||
Self::Linux
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "dragonfly"
|
||||
))]
|
||||
#[cfg(any(target_os = "macos", target_os = "dragonfly"))]
|
||||
pub fn current() -> Self {
|
||||
Self::OsX
|
||||
}
|
||||
|
|
@ -73,6 +76,21 @@ impl PlatformType {
|
|||
Self::Android
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "freebsd"))]
|
||||
pub fn current() -> Self {
|
||||
Self::FreeBsd
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "netbsd"))]
|
||||
pub fn current() -> Self {
|
||||
Self::NetBsd
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "openbsd"))]
|
||||
pub fn current() -> Self {
|
||||
Self::OpenBsd
|
||||
}
|
||||
|
||||
#[cfg(not(any(
|
||||
target_os = "linux",
|
||||
target_os = "macos",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue