From abbb56a8f7f0d6b3f1465505d1db6439a13815da Mon Sep 17 00:00:00 2001 From: marchersimon Date: Fri, 26 Mar 2021 21:03:45 +0100 Subject: [PATCH 1/5] change -o to -p and --os to --platform --- README.md | 4 ++-- bin/completion/bash/tldr | 4 ++-- bin/completion/zsh/_tldr | 2 +- bin/tldr | 4 ++-- lib/search.js | 2 +- test/functional-test.sh | 10 +++++----- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d171de49..916fba47 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ npm install -g tldr To see tldr pages: - `tldr ` show examples for this command -- `tldr --os=` show command page for the given platform (`linux`, `osx`, `sunos`, `windows`) +- `tldr --platform=` show command page for the given platform (`linux`, `osx`, `sunos`, `windows`) - `tldr --search ""` search all pages for the query - `tldr --linux ` show command page for Linux - `tldr --osx ` show command page for OSX @@ -91,7 +91,7 @@ you can put it in the config file: The default platform value can be overwritten with command-line option: ```shell -tldr du --os=osx +tldr du --platform=osx ``` As a contributor, you can also point to your own fork containing the `tldr.zip` file. The file is just a zipped version of the entire tldr repo: diff --git a/bin/completion/bash/tldr b/bin/completion/bash/tldr index af34bba8..5502a957 100644 --- a/bin/completion/bash/tldr +++ b/bin/completion/bash/tldr @@ -20,7 +20,7 @@ OPTIONS='-V --render -m --markdown --o +-p --linux --osx --sunos @@ -56,7 +56,7 @@ function _tldr_autocomplete { COMPREPLY=(`compgen -f $cur`) ;; - -o|--os) + -p|--platform) COMPREPLY=(`compgen -W "$OS_TYPES" $cur`) ;; diff --git a/bin/completion/zsh/_tldr b/bin/completion/zsh/_tldr index 6ae80e54..65dfaecc 100644 --- a/bin/completion/zsh/_tldr +++ b/bin/completion/zsh/_tldr @@ -15,7 +15,7 @@ _arguments \ '(- *)'{-e,--random-example}'[show a random example]' \ '(- *)'{-m,--markdown}'[show the original markdown format page]' \ '(-f --render)'{-f,--render}'[render a specific markdown file]:markdown file:_files -/' \ - '(-o --os)'{-o,--os}"[override operating system]:os:${oses}" \ + '(-p --platform)'{-p,--platform}"[override operating system]:os:${oses}" \ '--linux[override operating system with Linux]' \ '--osx[override operating system with OSX]' \ '--sunos[override operating system with SunOS]' \ diff --git a/bin/tldr b/bin/tldr index b6a52aae..cbb63c74 100755 --- a/bin/tldr +++ b/bin/tldr @@ -20,7 +20,7 @@ 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('-o, --os [type]', 'Override the operating system [linux, osx, sunos, windows]') + .option('-p, --platform [type]', 'Override the operating system [linux, osx, sunos, windows]') .option('--linux', 'Override the operating system with Linux') .option('--osx', 'Override the operating system with OSX') .option('--sunos', 'Override the operating system with SunOS') @@ -37,7 +37,7 @@ const help = ` Examples: $ tldr tar - $ tldr du --os=linux + $ tldr du --platform=linux $ tldr --search "create symbolic link to file" $ tldr --list $ tldr --list-all diff --git a/lib/search.js b/lib/search.js index 12900540..31afa104 100644 --- a/lib/search.js +++ b/lib/search.js @@ -189,7 +189,7 @@ exports.printResults = (results, config) => { // Prints the passed results to the console. // If the command is not available for the current platform, // it lists the available platforms instead. - // Example: tldr --search print directory tree --os sunos prints: + // Example: tldr --search print directory tree --platform sunos prints: // $ tree (Available on: linux, osx) index.getShortIndex().then((shortIndex) => { let outputs = new Set(); diff --git a/test/functional-test.sh b/test/functional-test.sh index 919f88db..17a96eca 100755 --- a/test/functional-test.sh +++ b/test/functional-test.sh @@ -6,11 +6,11 @@ alias tldr="node bin/tldr" function tldr-render-pages { tldr zip && \ - tldr du --os=linux && \ - tldr du --os=osx && \ - tldr du --os=linux --markdown && \ - tldr du --os=osx --markdown && \ - tldr du --os=windows --markdown && \ + tldr du --platform=linux && \ + tldr du --platform=osx && \ + tldr du --platform=linux --markdown && \ + tldr du --platform=osx --markdown && \ + tldr du --platform=windows --markdown && \ LANG= tldr --random && \ LANG= tldr --random-example && \ tldr --list && \ From 5e1b052af5b21f82b93e57bdc5caccf9203bddef Mon Sep 17 00:00:00 2001 From: bl-ue <54780737+bl-ue@users.noreply.github.com> Date: Fri, 26 Mar 2021 16:41:29 -0400 Subject: [PATCH 2/5] rename platform.js to platformUtils.js --- bin/tldr | 26 +++++++++++++------------- lib/cache.js | 4 ++-- lib/config.js | 6 +++--- lib/{platform.js => platformUtils.js} | 0 lib/search.js | 4 ++-- lib/tldr.js | 8 ++++---- test/cache.spec.js | 14 +++++++------- test/platform.spec.js | 18 +++++++++--------- 8 files changed, 40 insertions(+), 40 deletions(-) rename lib/{platform.js => platformUtils.js} (100%) diff --git a/bin/tldr b/bin/tldr index cbb63c74..417b7c64 100755 --- a/bin/tldr +++ b/bin/tldr @@ -4,7 +4,7 @@ const program = require('commander'); const pkg = require('../package'); const Tldr = require('../lib/tldr'); const config = require('../lib/config'); -const platform = require('../lib/platform'); +const platformUtils = require('../lib/platformUtils'); program .version(pkg.version, '-v, --version') @@ -20,11 +20,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 operating system [linux, osx, sunos, windows]') - .option('--linux', 'Override the operating system with Linux') - .option('--osx', 'Override the operating system with OSX') - .option('--sunos', 'Override the operating system with SunOS') - .option('--windows', 'Override the operating system with Windows') + .option('-p, --platform [type]', 'Override platform [linux, osx, sunos, windows]') + .option('--linux', 'Override platform with Linux') + .option('--osx', 'Override platform with OSX') + .option('--sunos', 'Override platform with SunOS') + .option('--windows', 'Override platform with Windows') .option('-t, --theme [theme]', 'Color theme (simple, base16, ocean)') .option('-s, --search [keywords]', 'Search pages using keywords') // @@ -61,25 +61,25 @@ program.on('--help', () => { program.parse(process.argv); if (program.linux) { - program.os = 'linux'; + program.platform = 'linux'; } if (program.osx) { - program.os = 'osx'; + program.platform = 'osx'; } if (program.sunos) { - program.os = 'sunos'; + program.platform = 'sunos'; } if (program.windows) { - program.os = 'windows'; + program.platform = 'windows'; } let cfg = config.get(); -if (program.os) { - if (platform.isSupported(program.os)) { - cfg.platform = program.os; +if (program.platform) { + if (platformUtils.isSupported(program.platform)) { + cfg.platform = program.platform; } } diff --git a/lib/cache.js b/lib/cache.js index ed1d23d6..4c83f1ba 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -4,7 +4,7 @@ const fs = require('fs-extra'); const os = require('os'); const path = require('path'); const remote = require('./remote'); -const platform = require('./platform'); +const platformUtils = require('./platformUtils'); const index = require('./index'); const utils = require('./utils'); @@ -21,7 +21,7 @@ class Cache { } getPage(page) { - let preferredPlatform = platform.getPreferredPlatformFolder(this.config); + let preferredPlatform = platformUtils.getPreferredPlatformFolder(this.config); const preferredLanguage = process.env.LANG || 'en'; return index.findPage(page, preferredPlatform, preferredLanguage) .then((folder) => { diff --git a/lib/config.js b/lib/config.js index 6d206fad..5facd4ad 100644 --- a/lib/config.js +++ b/lib/config.js @@ -4,6 +4,7 @@ const defaults = require('lodash/defaults'); const fs = require('fs'); const path = require('path'); const osHomedir = require('os').homedir; +let platformUtils = require('./platformUtils'); exports.get = () => { const DEFAULT = path.join(__dirname, '..', 'config.json'); @@ -38,8 +39,7 @@ exports.get = () => { }; function validatePlatform(os) { - let platform = require('./platform'); - if (os && !platform.isSupported(os)) { + if (os && !platformUtils.isSupported(os)) { return 'Unsupported platform : ' + os; } return null; @@ -100,4 +100,4 @@ function validateThemeItem(field, key) { return null; } return errMsg.join('\n'); -} \ No newline at end of file +} diff --git a/lib/platform.js b/lib/platformUtils.js similarity index 100% rename from lib/platform.js rename to lib/platformUtils.js diff --git a/lib/search.js b/lib/search.js index 31afa104..bdd8885d 100644 --- a/lib/search.js +++ b/lib/search.js @@ -7,7 +7,7 @@ const natural = require('natural'); const config = require('./config'); const utils = require('./utils'); const index = require('./index'); -const platform = require('./platform'); +const platformUtils = require('./platformUtils'); const CACHE_FOLDER = path.join(config.get().cache, 'cache'); @@ -193,7 +193,7 @@ exports.printResults = (results, config) => { // $ tree (Available on: linux, osx) index.getShortIndex().then((shortIndex) => { let outputs = new Set(); - let preferredPlatform = platform.getPreferredPlatform(config); + let preferredPlatform = platformUtils.getPreferredPlatform(config); results.forEach((elem) => { let cmdname = utils.parsePagename(elem.file); let output = ' $ ' + cmdname; diff --git a/lib/tldr.js b/lib/tldr.js index 80b90d81..6f0ab21c 100644 --- a/lib/tldr.js +++ b/lib/tldr.js @@ -6,7 +6,7 @@ const ms = require('ms'); const ora = require('ora'); const Cache = require('./cache'); const search = require('./search'); -const platform = require('./platform'); +const platformUtils = require('./platformUtils'); const messages = require('./messages'); const parser = require('./parser'); const render = require('./render'); @@ -22,7 +22,7 @@ class Tldr { } list(singleColumn) { - let os = platform.getPreferredPlatformFolder(this.config); + let os = platformUtils.getPreferredPlatformFolder(this.config); return index.commandsFor(os) .then((commands) => { return this.printPages(commands, singleColumn); @@ -41,7 +41,7 @@ class Tldr { } random(options) { - let os = platform.getPreferredPlatformFolder(this.config); + let os = platformUtils.getPreferredPlatformFolder(this.config); return index.commandsFor(os) .then((pages) => { if (pages.length === 0) { @@ -57,7 +57,7 @@ class Tldr { } randomExample() { - let os = platform.getPreferredPlatformFolder(this.config); + let os = platformUtils.getPreferredPlatformFolder(this.config); return index.commandsFor(os) .then((pages) => { if (pages.length === 0) { diff --git a/test/cache.spec.js b/test/cache.spec.js index 2ab82706..0e292eb2 100644 --- a/test/cache.spec.js +++ b/test/cache.spec.js @@ -8,7 +8,7 @@ const path = require('path'); const fs = require('fs-extra'); const index = require('../lib/index'); const remote = require('../lib/remote'); -const platform = require('../lib/platform'); +const platformUtils = require('../lib/platformUtils'); describe('Cache', () => { @@ -79,7 +79,7 @@ describe('Cache', () => { it('should return page contents for ls', () => { sinon.stub(fs, 'readFile').resolves('# ls\n> ls page'); - sinon.stub(platform, 'getPreferredPlatformFolder').returns('osx'); + sinon.stub(platformUtils, 'getPreferredPlatformFolder').returns('osx'); sinon.stub(index, 'findPage').resolves('osx'); const cache = new Cache(config.get()); return cache.getPage('ls') @@ -87,28 +87,28 @@ describe('Cache', () => { should.exist(content); content.should.startWith('# ls'); fs.readFile.restore(); - platform.getPreferredPlatformFolder.restore(); + platformUtils.getPreferredPlatformFolder.restore(); index.findPage.restore(); }); }); it('should return empty contents for svcs on OSX', () =>{ sinon.stub(fs, 'readFile').resolves('# svcs\n> svcs'); - sinon.stub(platform, 'getPreferredPlatformFolder').returns('osx'); + sinon.stub(platformUtils, 'getPreferredPlatformFolder').returns('osx'); sinon.stub(index, 'findPage').resolves(null); const cache = new Cache(config.get()); return cache.getPage('svc') .then((content) => { should.not.exist(content); fs.readFile.restore(); - platform.getPreferredPlatformFolder.restore(); + platformUtils.getPreferredPlatformFolder.restore(); index.findPage.restore(); }); }); it('should return page contents for svcs on SunOS', () => { sinon.stub(fs, 'readFile').resolves('# svcs\n> svcs'); - sinon.stub(platform, 'getPreferredPlatformFolder').returns('sunos'); + sinon.stub(platformUtils, 'getPreferredPlatformFolder').returns('sunos'); sinon.stub(index, 'findPage').resolves('svcs'); const cache = new Cache(config.get()); return cache.getPage('svcs') @@ -116,7 +116,7 @@ describe('Cache', () => { should.exist(content); content.should.startWith('# svcs'); fs.readFile.restore(); - platform.getPreferredPlatformFolder.restore(); + platformUtils.getPreferredPlatformFolder.restore(); index.findPage.restore(); }); }); diff --git a/test/platform.spec.js b/test/platform.spec.js index aa0842d3..401785df 100644 --- a/test/platform.spec.js +++ b/test/platform.spec.js @@ -3,7 +3,7 @@ const os = require('os'); const config = require('../lib/config'); const sinon = require('sinon'); -const platform = require('../lib/platform'); +const platformUtils = require('../lib/platformUtils'); describe('Platform', () => { @@ -20,7 +20,7 @@ describe('Platform', () => { it('should return the running platform with no configuration', () => { os.platform.onCall(0).returns('darwin'); this.config = {}; - platform.getPreferredPlatform(this.config).should.eql('darwin'); + platformUtils.getPreferredPlatform(this.config).should.eql('darwin'); }); it('should overwrite the running platform if configured', () => { @@ -28,7 +28,7 @@ describe('Platform', () => { this.config = { platform: 'linux' }; - platform.getPreferredPlatform(this.config).should.eql('linux'); + platformUtils.getPreferredPlatform(this.config).should.eql('linux'); }); it('should return current system platform if configuration is wrong', () => { @@ -36,17 +36,17 @@ describe('Platform', () => { this.config = { platform: 'there_is_no_such_platform' }; - platform.getPreferredPlatform(this.config).should.eql('darwin'); + platformUtils.getPreferredPlatform(this.config).should.eql('darwin'); }); }); describe('isSupported', () => { it('should tell that Linux, OSX, SunOS and Win32 are supported', () => { - platform.isSupported('osx').should.eql(true); - platform.isSupported('linux').should.eql(true); - platform.isSupported('sunos').should.eql(true); - platform.isSupported('windows').should.eql(true); - platform.isSupported('ios').should.eql(false); + platformUtils.isSupported('osx').should.eql(true); + platformUtils.isSupported('linux').should.eql(true); + platformUtils.isSupported('sunos').should.eql(true); + platformUtils.isSupported('windows').should.eql(true); + platformUtils.isSupported('ios').should.eql(false); }); }); }); From 39ce9480fb9c229759f968701401b15c751e8ee9 Mon Sep 17 00:00:00 2001 From: bl-ue <54780737+bl-ue@users.noreply.github.com> Date: Fri, 26 Mar 2021 16:53:24 -0400 Subject: [PATCH 3/5] os/operating system -> platform --- bin/completion/bash/tldr | 4 ++-- bin/completion/zsh/_tldr | 14 +++++++------- lib/config.js | 6 +++--- lib/index.js | 20 ++++++++++---------- lib/search.js | 2 +- lib/tldr.js | 12 ++++++------ test/index.spec.js | 18 +++++++++--------- 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/bin/completion/bash/tldr b/bin/completion/bash/tldr index 5502a957..8fe82f10 100644 --- a/bin/completion/bash/tldr +++ b/bin/completion/bash/tldr @@ -2,7 +2,7 @@ BUILTIN_THEMES="single base16 ocean" -OS_TYPES="linux osx sunos windows" +PLATFORMS="linux osx sunos windows" OPTIONS='-V --version @@ -57,7 +57,7 @@ function _tldr_autocomplete { ;; -p|--platform) - COMPREPLY=(`compgen -W "$OS_TYPES" $cur`) + COMPREPLY=(`compgen -W "$PLATFORMS" $cur`) ;; -t|--theme) diff --git a/bin/completion/zsh/_tldr b/bin/completion/zsh/_tldr index 65dfaecc..a50666ee 100644 --- a/bin/completion/zsh/_tldr +++ b/bin/completion/zsh/_tldr @@ -1,8 +1,8 @@ #compdef tldr -local -a pages oses +local -a pages platforms pages=$(tldr -a1) -oses='( linux osx sunos windows )' +platforms='( linux osx sunos windows )' _arguments \ '(- *)'{-h,--help}'[show help]' \ @@ -15,11 +15,11 @@ _arguments \ '(- *)'{-e,--random-example}'[show a random example]' \ '(- *)'{-m,--markdown}'[show the original markdown format page]' \ '(-f --render)'{-f,--render}'[render a specific markdown file]:markdown file:_files -/' \ - '(-p --platform)'{-p,--platform}"[override operating system]:os:${oses}" \ - '--linux[override operating system with Linux]' \ - '--osx[override operating system with OSX]' \ - '--sunos[override operating system with SunOS]' \ - '--windows[override operating system with Windows]' \ + '(-p --platform)'{-p,--platform}"[override platform]:platform:${platforms}" \ + '--linux[override platform with Linux]' \ + '--osx[override platform with OSX]' \ + '--sunos[override platform with SunOS]' \ + '--windows[override platform with Windows]' \ '(- *)'{-u,--update}'[update local cache]' \ '(- *)'{-c,--clear-cache}'[clear local cache]' \ "*:page:(${pages})" && return 0 diff --git a/lib/config.js b/lib/config.js index 5facd4ad..1cf2ad0d 100644 --- a/lib/config.js +++ b/lib/config.js @@ -38,9 +38,9 @@ exports.get = () => { return merged; }; -function validatePlatform(os) { - if (os && !platformUtils.isSupported(os)) { - return 'Unsupported platform : ' + os; +function validatePlatform(platform) { + if (platform && !platformUtils.isSupported(platform)) { + return 'Unsupported platform : ' + platform; } return null; } diff --git a/lib/index.js b/lib/index.js index d116b5b5..7f6f2236 100644 --- a/lib/index.js +++ b/lib/index.js @@ -59,12 +59,12 @@ function findPage(page, preferredPlatform, preferredLanguage) { targetPlatform = 'common'; } else if (targets.length > 0 && hasLang(targets, preferredLanguage)) { targetLanguage = preferredLanguage; - targetPlatform = targets[0].os; - console.log(`Command ${page} does not exist for the host platform. Displaying the page from ${targets[0].os} platform`); + targetPlatform = targets[0].platform; + console.log(`Command ${page} does not exist for the host platform. Displaying the page from ${targets[0].platform} platform`); } else if (targets.length > 0 && hasLang(targets, 'en')) { targetLanguage = 'en'; - targetPlatform = targets[0].os; - console.log(`Command ${page} does not exist for the host platform. Displaying the page from ${targets[0].os} platform`); + targetPlatform = targets[0].platform; + console.log(`Command ${page} does not exist for the host platform. Displaying the page from ${targets[0].platform} platform`); } if (!targetLanguage && !targetPlatform) { @@ -81,7 +81,7 @@ function findPage(page, preferredPlatform, preferredLanguage) { function hasPlatformLang(targets, preferredPlatform, preferredLanguage) { return targets.some((t) => { - return t.os === preferredPlatform && t.language === preferredLanguage; + return t.platform === preferredPlatform && t.language === preferredLanguage; }); } @@ -116,7 +116,7 @@ function commandsFor(platform) { let commands = Object.keys(idx) .filter((cmd) => { let targets = idx[cmd].targets; - let platforms = targets.map((t) => {return t.os;}); + let platforms = targets.map((t) => {return t.platform;}); return platforms.indexOf(platform) !== -1 || platforms.indexOf('common') !== -1; }) .sort(); @@ -187,24 +187,24 @@ function buildShortPagesIndex() { .then((files) => { files = files.filter(utils.isPage); let reducer = (index, file) => { - let os = utils.parsePlatform(file); + let platform = utils.parsePlatform(file); let page = utils.parsePagename(file); let language = utils.parseLanguage(file); if (index[page]) { let targets = index[page].targets; let needsPush = true; for (const target of targets) { - if (target.platform === os && target.language === language) { + if (target.platform === platform && target.language === language) { needsPush = false; continue; } } if (needsPush) { - targets.push({'os': os, 'language': language}); + targets.push({'platform': platform, 'language': language}); index[page].targets = targets; } } else { - index[page] = {targets: [{'os': os, 'language': language}]}; + index[page] = {targets: [{'platform': platform, 'language': language}]}; } return index; diff --git a/lib/search.js b/lib/search.js index bdd8885d..b322c98e 100644 --- a/lib/search.js +++ b/lib/search.js @@ -198,7 +198,7 @@ exports.printResults = (results, config) => { let cmdname = utils.parsePagename(elem.file); let output = ' $ ' + cmdname; let targets = shortIndex[cmdname]['targets']; - let platforms = targets.map((t) => {return t.os;}); + let platforms = targets.map((t) => {return t.platform;}); if (platforms.indexOf('common') === -1 && platforms.indexOf(preferredPlatform) === -1) { output += ' (Available on: ' + platforms.join(', ') + ')'; } diff --git a/lib/tldr.js b/lib/tldr.js index 6f0ab21c..84b2a7a1 100644 --- a/lib/tldr.js +++ b/lib/tldr.js @@ -22,8 +22,8 @@ class Tldr { } list(singleColumn) { - let os = platformUtils.getPreferredPlatformFolder(this.config); - return index.commandsFor(os) + let platform = platformUtils.getPreferredPlatformFolder(this.config); + return index.commandsFor(platform) .then((commands) => { return this.printPages(commands, singleColumn); }); @@ -41,8 +41,8 @@ class Tldr { } random(options) { - let os = platformUtils.getPreferredPlatformFolder(this.config); - return index.commandsFor(os) + let platform = platformUtils.getPreferredPlatformFolder(this.config); + return index.commandsFor(platform) .then((pages) => { if (pages.length === 0) { throw new Error(messages.emptyCache()); @@ -57,8 +57,8 @@ class Tldr { } randomExample() { - let os = platformUtils.getPreferredPlatformFolder(this.config); - return index.commandsFor(os) + let platform = platformUtils.getPreferredPlatformFolder(this.config); + return index.commandsFor(platform) .then((pages) => { if (pages.length === 0) { throw new Error(messages.emptyCache()); diff --git a/test/index.spec.js b/test/index.spec.js index f2cb7dd0..7ee76674 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -208,15 +208,15 @@ describe('Index', () => { return index.getShortIndex() .then((idx) => { idx.should.deepEqual({ - apk: {targets: [{language: 'en', os: 'linux'}, {language: 'zh', os: 'linux'}]}, - cp: {targets: [{language: 'en', os: 'common'}, {language: 'it', os: 'common'}, {language: 'ta', os: 'common'}]}, - dd: {targets: [{language: 'en', os: 'linux'}, {language: 'en', os: 'osx'}, {language: 'en', os: 'sunos'}]}, - du: {targets: [{language: 'en', os: 'linux'}, {language: 'en', os: 'osx'}, {language: 'en', os: 'sunos'}]}, - git: {targets: [{language: 'en', os: 'common'}]}, - ln: {targets: [{language: 'en', os: 'common'}]}, - ls: {targets: [{language: 'en', os: 'common'}]}, - svcs: {targets: [{language: 'en', os: 'sunos'}]}, - top: {targets: [{language: 'en', os: 'linux'}, {language: 'en', os: 'osx'}]}, + apk: {targets: [{language: 'en', platform: 'linux'}, {language: 'zh', platform: 'linux'}]}, + cp: {targets: [{language: 'en', platform: 'common'}, {language: 'it', platform: 'common'}, {language: 'ta', platform: 'common'}]}, + dd: {targets: [{language: 'en', platform: 'linux'}, {language: 'en', platform: 'osx'}, {language: 'en', platform: 'sunos'}]}, + du: {targets: [{language: 'en', platform: 'linux'}, {language: 'en', platform: 'osx'}, {language: 'en', platform: 'sunos'}]}, + git: {targets: [{language: 'en', platform: 'common'}]}, + ln: {targets: [{language: 'en', platform: 'common'}]}, + ls: {targets: [{language: 'en', platform: 'common'}]}, + svcs: {targets: [{language: 'en', platform: 'sunos'}]}, + top: {targets: [{language: 'en', platform: 'linux'}, {language: 'en', platform: 'osx'}]}, }); }); }); From 881ddd837bbdb0ef1b2f313a04c69bf100b9b685 Mon Sep 17 00:00:00 2001 From: bl-ue <54780737+bl-ue@users.noreply.github.com> Date: Sun, 28 Mar 2021 18:18:29 -0400 Subject: [PATCH 4/5] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dario Vladović --- bin/tldr | 2 +- lib/index.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/tldr b/bin/tldr index 417b7c64..4bec5928 100755 --- a/bin/tldr +++ b/bin/tldr @@ -20,7 +20,7 @@ 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 platform [linux, osx, sunos, windows]') + .option('-p, --platform [platform]', 'Override platform [linux, osx, sunos, windows]') .option('--linux', 'Override platform with Linux') .option('--osx', 'Override platform with OSX') .option('--sunos', 'Override platform with SunOS') diff --git a/lib/index.js b/lib/index.js index 7f6f2236..b1a1b3a7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -60,11 +60,11 @@ function findPage(page, preferredPlatform, preferredLanguage) { } else if (targets.length > 0 && hasLang(targets, preferredLanguage)) { targetLanguage = preferredLanguage; targetPlatform = targets[0].platform; - console.log(`Command ${page} does not exist for the host platform. Displaying the page from ${targets[0].platform} platform`); + console.log(`Command ${page} does not exist for the host platform. Displaying the page from ${targetPlatform} platform`); } else if (targets.length > 0 && hasLang(targets, 'en')) { targetLanguage = 'en'; targetPlatform = targets[0].platform; - console.log(`Command ${page} does not exist for the host platform. Displaying the page from ${targets[0].platform} platform`); + console.log(`Command ${page} does not exist for the host platform. Displaying the page from ${targetPlatorm} platform`); } if (!targetLanguage && !targetPlatform) { @@ -200,11 +200,11 @@ function buildShortPagesIndex() { } } if (needsPush) { - targets.push({'platform': platform, 'language': language}); + targets.push({ platform, language }); index[page].targets = targets; } } else { - index[page] = {targets: [{'platform': platform, 'language': language}]}; + index[page] = { targets: [{ platform, language }] }; } return index; From b532a0f21d0939d8f884d115d011253a74f8fb6e Mon Sep 17 00:00:00 2001 From: bl-ue <54780737+bl-ue@users.noreply.github.com> Date: Sun, 28 Mar 2021 18:42:37 -0400 Subject: [PATCH 5/5] Update lib/index.js --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index b1a1b3a7..5cb9653f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -64,7 +64,7 @@ function findPage(page, preferredPlatform, preferredLanguage) { } else if (targets.length > 0 && hasLang(targets, 'en')) { targetLanguage = 'en'; targetPlatform = targets[0].platform; - console.log(`Command ${page} does not exist for the host platform. Displaying the page from ${targetPlatorm} platform`); + console.log(`Command ${page} does not exist for the host platform. Displaying the page from ${targetPlatform} platform`); } if (!targetLanguage && !targetPlatform) {