Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for android platform #274

Merged
merged 2 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion completion/bash_tealdeer
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _tealdeer()
return
;;
-p|--platform)
COMPREPLY=( $(compgen -W 'linux macos sunos windows' -- "${cur}") )
COMPREPLY=( $(compgen -W 'linux macos sunos windows android' -- "${cur}") )
return
;;
--color)
Expand Down
2 changes: 1 addition & 1 deletion completion/fish_tealdeer
Original file line number Diff line number Diff line change
Expand Up @@ -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'
complete -c tldr -s p -l platform -d 'Override the operating system.' -xa 'linux macos sunos windows android'
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
complete -c tldr -s c -l clear-cache -d 'Clear the local cache.' -f
Expand Down
1 change: 1 addition & 0 deletions completion/zsh_tealdeer
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ _tealdeer() {
macos
sunos
windows
android
))'
"($I -L --language)"{-L,--language}"[Override the language settings]:lang"
"($I -u --update)"{-u,--update}"[Update the local cache]"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ OPTIONS:
-l, --list List all commands in the cache
-f, --render <FILE> Render a specific markdown file
-p, --platform <PLATFORM> Override the operating system [possible values: linux, macos,
windows, sunos, osx]
windows, sunos, osx, android]
-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
Expand Down
1 change: 1 addition & 0 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ impl Cache {
PlatformType::OsX => "osx",
PlatformType::SunOs => "sunos",
PlatformType::Windows => "windows",
PlatformType::Android => "android",
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub(crate) struct Args {
#[clap(
short = 'p',
long = "platform",
possible_values = ["linux", "macos", "windows", "sunos", "osx"],
possible_values = ["linux", "macos", "windows", "sunos", "osx", "android"],
niklasmohrin marked this conversation as resolved.
Show resolved Hide resolved
)]
pub platform: Option<PlatformType>,

Expand Down
13 changes: 11 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub enum PlatformType {
OsX,
SunOs,
Windows,
Android,
dbrgn marked this conversation as resolved.
Show resolved Hide resolved
}

impl fmt::Display for PlatformType {
Expand All @@ -22,6 +23,7 @@ impl fmt::Display for PlatformType {
Self::OsX => write!(f, "macOS / BSD"),
Self::SunOs => write!(f, "SunOS"),
Self::Windows => write!(f, "Windows"),
Self::Android => write!(f, "Android"),
}
}
}
Expand All @@ -35,8 +37,9 @@ impl str::FromStr for PlatformType {
"osx" | "macos" => Ok(Self::OsX),
"sunos" => Ok(Self::SunOs),
"windows" => Ok(Self::Windows),
"android" => Ok(Self::Android),
other => Err(anyhow!(
"Unknown OS: {}. Possible values: linux, macos, osx, sunos, windows",
"Unknown OS: {}. Possible values: linux, macos, osx, sunos, windows, android",
other
)),
}
Expand Down Expand Up @@ -65,14 +68,20 @@ impl PlatformType {
Self::Windows
}

#[cfg(target_os = "android")]
pub fn current() -> Self {
Self::Android
}

#[cfg(not(any(
target_os = "linux",
target_os = "macos",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "dragonfly",
target_os = "windows"
target_os = "windows",
target_os = "android",
)))]
pub fn current() -> Self {
Self::Other
Expand Down