-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
feat (3.4.0): add platform option, Android and BSD platforms #421
Conversation
Signed-off-by: K.B.Dharun Krishna <[email protected]>
Signed-off-by: K.B.Dharun Krishna <[email protected]>
Signed-off-by: K.B.Dharun Krishna <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Any update on this? |
I am planning on adding support for openbsd platform too in this, will do this later today, along with another change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM to me.
We could simplify adding new platforms by doing something like this:
diff --git a/bin/tldr b/bin/tldr
index 59e0b91..21e28ba 100755
--- a/bin/tldr
+++ b/bin/tldr
@@ -22,12 +22,11 @@ program
.option('-e, --random-example', 'Show a random example')
.option('-f, --render [file]', 'Render a specific markdown [file]')
.option('-m, --markdown', 'Output in markdown format')
- .option('-p, --platform [type]', 'Override the current platform [android, linux, osx, sunos, windows]')
- .option('--android', 'Override the platform with Android')
- .option('--linux', 'Override the platform with Linux')
- .option('--osx', 'Override the platform with OSX')
- .option('--sunos', 'Override the platform with SunOS')
- .option('--windows', 'Override the platform with Windows')
+ .option('-p, --platform [type]', `Override the current platform [${platforms.supportedPlatforms.join(', ')}]`);
+for (const platform of platforms.supportedPlatforms) {
+ program.option(`--${platform}`, `Override the platform with ${platform}`);
+}
+program
.alias('-o', '-p') // Alias -o to -p
.alias('--os', '--platform') // Alias --os to --platform
.option('-t, --theme [theme]', 'Color theme (simple, base16, ocean)')
@@ -65,24 +64,10 @@ program.on('--help', () => {
program.parse(process.argv);
-if(program.android) {
- program.platform = 'android';
-}
-
-if (program.linux) {
- program.platform = 'linux';
-}
-
-if (program.osx) {
- program.platform = 'osx';
-}
-
-if (program.sunos) {
- program.platform = 'sunos';
-}
-
-if (program.windows) {
- program.platform = 'windows';
+for (const platform in platforms.supportedPlatforms) {
+ if (program[platform]) {
+ program.platform = platform;
+ }
}
let cfg = config.get();
diff --git a/lib/platforms.js b/lib/platforms.js
index c938363..25f6a49 100644
--- a/lib/platforms.js
+++ b/lib/platforms.js
@@ -12,6 +12,8 @@ const folders = {
'win32': 'windows'
};
+const supportedPlatforms = Array.from(new Set(Object.values(folders))).sort();
+
// Check if the platform is there in the list of platforms or not
function isSupported(platform) {
return Object.prototype.hasOwnProperty.call(folders, platform);
@@ -36,5 +38,6 @@ function getPreferredPlatformFolder(config) {
module.exports = {
isSupported,
getPreferredPlatform,
- getPreferredPlatformFolder
+ getPreferredPlatformFolder,
+ supportedPlatforms
};
Now won't fill up bin/tldr
with nearly identical if statements as new platforms are added.
Co-authored-by: Matthew Peveler <[email protected]>
Signed-off-by: K.B.Dharun Krishna <[email protected]>
Signed-off-by: K.B.Dharun Krishna <[email protected]>
Signed-off-by: K.B.Dharun Krishna <[email protected]>
Signed-off-by: K.B.Dharun Krishna <[email protected]>
Signed-off-by: K.B.Dharun Krishna <[email protected]>
@MasterOdin I have rearranged the options in alphabetical order as requested. Changes in the last 3 commits
In Reference outputs➜ bin git:(feat/platform-option) ✗ ./tldr -v
v3.3.8
Client Specification: 2.0
➜ bin git:(feat/platform-option) ✗ ./tldr -h
Usage: tldr|-o command [options]
Simplified and community-driven man pages
Options:
-v, --version Display version
-l, --list List all commands for the chosen platform in the cache
-a, --list-all List all commands in the cache
-1, --single-column List single command per line (use with options -l or -a)
-r, --random Show a random command
-e, --random-example Show a random example
-f, --render [file] Render a specific markdown [file]
-m, --markdown Output in markdown format
-p, --platform [type] Override the current platform [android, darwin, freebsd, linux, macos, netbsd, openbsd, osx, sunos,
win32, windows]
--android Override the platform with android
--darwin Override the platform with darwin
--freebsd Override the platform with freebsd
--linux Override the platform with linux
--macos Override the platform with macos
--netbsd Override the platform with netbsd
--openbsd Override the platform with openbsd
--osx Override the platform with osx
--sunos Override the platform with sunos
--win32 Override the platform with win32
--windows Override the platform with windows
-t, --theme [theme] Color theme (simple, base16, ocean)
-s, --search [keywords] Search pages using keywords
-u, --update Update the local cache
-c, --clear-cache Clear the local cache
-h, --help Show this help message
Examples:
$ tldr tar
$ tldr du --platform=linux
$ tldr --search "create symbolic link to file"
$ tldr --list
$ tldr --list-all
$ tldr --random
$ tldr --random-example
To control the cache:
$ tldr --update
$ tldr --clear-cache
To render a local file (for testing):
$ tldr --render /path/to/file.md |
Signed-off-by: K.B.Dharun Krishna <[email protected]>
Signed-off-by: K.B.Dharun Krishna <[email protected]>
Changes in last commitUpdated ContentThis fixes #395 where the GPG page would render with broken mail addresses like: ➜ bin git:(feat/platform-option) ✗ ./tldr --render /home/kbdharunkrishna/Downloads/gpg.md
gpg
GNU Privacy Guard.
See gpg2 for GNU Privacy Guard 2. Most operating systems symlink gpg to gpg2.
More information: https://gnupg.org.
- Create a GPG public and private key interactively:
gpg --full-generate-key
- Sign doc.txt without encryption (writes output to doc.txt.asc):
gpg --clearsign doc.txt
- Encrypt and sign doc.txt for mailto:alice@example.com and mailto:bob@example.com (output to doc.txt.gpg):
gpg --encrypt --sign --recipient [email protected] --recipient [email protected] doc.txt
- Encrypt doc.txt with only a passphrase (output to doc.txt.gpg):
gpg --symmetric doc.txt
- Decrypt doc.txt.gpg (output to stdout):
gpg --decrypt doc.txt.gpg
- Import a public key:
gpg --import public.gpg
- Export public key for mailto:alice@example.com (output to stdout):
gpg --export --armor [email protected]
- Export private key for mailto:alice@example.com (output to stdout):
gpg --export-secret-keys --armor [email protected]
See also: gpg2 Post the changes, it now renders like this: ➜ bin git:(feat/platform-option) ✗ ./tldr --render /home/kbdharunkrishna/Downloads/gpg.md
gpg
GNU Privacy Guard.
See gpg2 for GNU Privacy Guard 2. Most operating systems symlink gpg to gpg2.
More information: https://gnupg.org.
- Create a GPG public and private key interactively:
gpg --full-generate-key
- Sign doc.txt without encryption (writes output to doc.txt.asc):
gpg --clearsign doc.txt
- Encrypt and sign doc.txt for [email protected] and [email protected] (output to doc.txt.gpg):
gpg --encrypt --sign --recipient [email protected] --recipient [email protected] doc.txt
- Encrypt doc.txt with only a passphrase (output to doc.txt.gpg):
gpg --symmetric doc.txt
- Decrypt doc.txt.gpg (output to stdout):
gpg --decrypt doc.txt.gpg
- Import a public key:
gpg --import public.gpg
- Export public key for [email protected] (output to stdout):
gpg --export --armor [email protected]
- Export private key for [email protected] (output to stdout):
gpg --export-secret-keys --armor [email protected]
See also: gpg2 |
I am removing myself. Feel free to merge when you have 2 or more approvals. |
Do we have an ultimatum to merge this? |
Waiting for @MasterOdin's review. After that is is GTG. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of changes here, but a quick review doesn't reveal any major issues here. I suggest this is okay to merge. Stopping short of an approval though, since I'm not as involved in implementing the node client. /cc @MasterOdin.
@agnivade Sorry for the ping, I have a few doubts about how we publish a new release to NPM (so that I can do it after this PR).
|
I think it would be helpful to have multiple people on the npm org, but unfortunately I don't have access. Might be worth checking who published recent versions of the Node client to see who to pester, @kbdharun? |
Hi @kbdharun! As far I know, and according to npm documentation, to publish a new release you must change the version in I will research more. |
Yes I release the npm package. Let me see if I can add you. |
Thanks received the invite, accepted it. Can you do the same for tldr-lint too?
|
Update: I have set up a new Org (https://www.npmjs.com/org/tldr-pages) in NPM. And added our existing unscoped |
Signed-off-by: K.B.Dharun Krishna <[email protected]>
Signed-off-by: K.B.Dharun Krishna <[email protected]>
I think this PR is GTG now will merge it (after passing checks), the only unreviewed change is in I have reverted the initial suggestion to add Other than that I have tested all other changes and the client works as expected. This is the changelog I prepared for the release: > [!WARNING]
> **Breaking change**: This release drops support for Node 14 and lower.
> [!NOTE]
> The default branch of this repository has been updated to `main`.
### Added
- Support to download cache for English and specific languages only based on the system's locale configuration (#420) (thanks @vivekjoshi556)
- Support for Android and BSD platforms (#421) (thanks @kbdharun)
- New `-p` and `--platform` option replacing `-o` and `--os` option (#421) (thanks @kbdharun)
### Fixed
- Escaping in Zsh autocompletion (#384) (thanks @nonZero)
- Variable assignment in Zsh (#386) (thanks @JakobMiksch)
- URL encoded email address rendering (#421) (thanks @kbdharun)
### Enhancements
- Added Funding information to `package.json` (#401) (thanks @kbdharun)
- Moved to `v2` format for `package-lock.json` (#409) (thanks @MasterOdin)
- Update homepage link to <https://tldr.sh> in `package.json` (#421) (thanks @kbdharun)
- The Client Specification version is now displayed when checking the version (#421) (thanks @kbdharun) |
Description
This PR updates the
--os
and-o
option to--platform
and-p
. This change would make the official client comply with the last client specification and #420 is expected to add support for the recent client specification 2.0. (Supersedes #337, thanks to the original authors and reviews for initial work on this transition)This PR also adds support for Android and other BSD platforms (
there might be another platformEdit. added it too).openbsd
in future, subscribe to tldr-pages/tldr#10698 to stay tunedChecklist
Please review this checklist before submitting a pull request.
npm run test:all
)Related PRs
Closes #337
Fixes #395