Giter Club home page Giter Club logo

tldr-c-client's Introduction

tldr c client

Build Status

A command line client for tldr, written in plain ISO C90.

Installing

On OS X, the client can be installed through Homebrew.

# To install the latest development version
brew install tldr --HEAD

# To install the latest stable release
brew install tldr

On Arch Linux, the client can be installed through the AUR using an AUR helper such as yay.

yay -S tldr-git

To build the latest version from the source:

git clone https://github.com/tldr-pages/tldr-c-client.git
cd tldr-c-client

sudo ./deps.sh           # install dependencies
make                # build tldr
sudo make install        # install tldr

To remove the version installed from the source:

sudo make uninstall

The default prefix for installation is /usr/local/bin.

Building

Building the tldr client is pretty straightforward.

Requirements

  • clang/gcc
  • libcurl (brew install curl / apt-get install libcurl-dev / apt-get install libcurl4-openssl-dev)
  • libzip (brew install libzip / apt-get install libzip-dev)
  • pkg-config (brew install pkg-config / apt-get install pkg-config)

Compiling

The Makefile in the root directory has all you need for building the project.

Just call make and tldr will build itself.

make

Autocompletion

Autocompletion is supported for bash, zsh, and fish and can be added by sourcing the correct autocompletion file.

The files autocomplete.zsh, autocomplete.bash, and autocomplete.fish can be found in the autocomplete folder in the root of the repository.

Installation

To install the autocompletion, just move the script for your shell to an easy to access the directory (like your home directory), and source it in your .bashrc or .zshrc.

Example for zsh:

mv autocomplete/complete.zsh ~/.tldr.complete
echo "source ~/.tldr.complete" >> ~/.zshrc

Usage

usage: tldr [OPTION]... PAGE

available commands:
    -h, --help              print this help and exit
    -C, --color             force color display
    -p, --platform=PLATFORM select platform, supported are linux / osx / sunos / windows / common
    -r, --render=PATH       render a local page for testing purposes
    -u, --update            update local database
    -v, --version           print version and exit
    -c, --clear-cache       clear local database
    -V, --verbose           display verbose output (when used with --clear-cache or --update)
    -l, --list              list all entries in the local database

Configuration

To prevent tldr from automatically updating its database, set the environment variable TLDR_AUTO_UPDATE_DISABLED.

Contributing

Please read the CONTRIBUTING.md for details.

License

The MIT License (MIT) - see LICENSE for details.

tldr-c-client's People

Contributors

4g3nt avatar ar7eniyan avatar bl-ue avatar cleanmachine1 avatar iacore avatar idealhack avatar kbdharun avatar leandros avatar marchersimon avatar mark1626 avatar masterodin avatar navarroaxel avatar nicokosi avatar owenvoke avatar packrat386 avatar parth avatar pixelcmtd avatar rastersize avatar riesentoaster avatar rtrigg avatar sbrl avatar sethfalco avatar superatomic avatar turbobasic avatar vedaant-rajoo avatar vinkla avatar waldyrious avatar yonezzzet avatar zlatanvasovic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tldr-c-client's Issues

Bash on Ubuntu on Windows - TLDR does not find pages

Reproduction Rate

I could reproduce the issue each time I tried to print any TLDR page.

Steps to Reproduce

  1. Install Windows Subsystem for Linux.
  2. Install Ubuntu on Windows.
  3. Run Bash on Ubuntu on Windows.
  4. Install linuxbrew. There is installation instruction on http://linuxbrew.sh.
  5. Install TLDR C++ client: brew update and brew install tldr.
  6. Try to print any TLDR page.

Result

$ tldr tldr
This page doesn't exist yet!
Submit new pages here: https://github.com/tldr-pages/tldr
$ tldr apt
This page doesn't exist yet!
Submit new pages here: https://github.com/tldr-pages/tldr

Expected Result

TLDR pages

Additional Information

Windows Subsystem for Linux, Bash on Ubuntu on Windows
TLDR C++ has been installed with linuxbrew

The issue might be related to issue #33 - TLDR local database cannot be updated.

Error on Mac 11.6 with brew install tldr

when i type
tldr
it appears

Error: Downloading File: https://github.com/tldr-pages/tldr/archive/main.zip
This page doesn't exist yet!
Submit new pages here: https://github.com/tldr-pages/tldr

tldr client does not handle ctrl+c properly

Reproduction Rate

everytime

Steps to Reproduce

~ $tldr j
Local data is older than two weeks, use --update to update it. >>>>> this line is in red

(ctrl-c here)
~ $asdf >>>>> these are also in red!
-bash: asdf: command not found >>>>> these are also in red!

screen shot 2018-10-08 at 1 11 12 pm

Result

bash text should go back to the way it was before

Expected Result

bash text is still red

Additional Information

~ $tldr --version
Local data is older than two weeks, use --update to update it.

tldr v1.3.0 (v1.3.0)
Copyright (C) 2016 Arvid Gerstmann
Source available at https://github.com/tldr-pages/tldr-cpp-client
~ $

Error: updating results in error

Reproduction Rate

  • always

Steps to Reproduce

tldr -u

Result

Error: Could Not Rename: /tmp/tldr4aQHBc/tldr-master to /Volumes/External/Users/matt/.tldrc/tldr-master/

Expected Result

  • should update

Additional Information

  • perhaps related to the master->main branch name change at tldr?

Cut a new release?

I'm wanting to submit a HomeBrew formula for this to the main Homebrew repository, would you be able to cut a new release at some point that I could use?

'tldr --list' segfaults on macOS

Reproduction Rate

3 / 3 times

Steps to Reproduce

run tldr --list

Result

Segmentation fault

Expected Result

A list of all entires in the database

Additional Information

tldr: 1.4.2
macOS 12.1 (12C52)

tldr --list results in a segfault. tldr -l results in tldr: option '-l' is ambiguous (which may be a separate bug)

I haven't reset the cache or any other artifacts in case they are useful in reproducing.

Full crash report attached. Translated report from Console.app below:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               tldr [39126]
Path:                  /usr/local/Cellar/tldr/1.4.2/bin/tldr
Identifier:            tldr
Version:               ???
Code Type:             X86-64 (Native)
Parent Process:        zsh [36476]
Responsible:           iTerm2 [651]
User ID:               503

Date/Time:             2021-12-21 19:48:26.8398 -0800
OS Version:            macOS 12.1 (21C52)
Report Version:        12
Bridge OS Version:     6.1 (19P647)
Anonymous UUID:        11B31165-9192-89A0-D780-9093191C32D6

Sleep/Wake UUID:       12E9DD6D-D639-44C3-9730-54F7087A6E1C

Time Awake Since Boot: 6900 seconds
Time Since Wake:       1745 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000040
Exception Codes:       0x0000000000000001, 0x0000000000000040
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [39126]

VM Region Info: 0x40 is not in any region.  Bytes before following region: 4417503168
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      1074dc000-1074e4000    [   32K] r-x/r-x SM=COW  ....4.2/bin/tldr

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_pthread.dylib       	    0x7ff80be2d94e pthread_mutex_lock + 4
1   libsystem_c.dylib             	    0x7ff80bd04a7d readdir$INODE64 + 22
2   tldr                          	       0x1074e2dbd parse_tldrlist + 228
3   tldr                          	       0x1074e2c87 print_tldrlist + 361
4   tldr                          	       0x1074e3150 main + 703
5   dyld                          	       0x115d434fe start + 462


Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000000  rcx: 0x00007ff80bdf64fe  rdx: 0xffffffffffffffff
  rdi: 0x0000000000000040  rsi: 0x0000000001100004  rbp: 0x00007ff7b8a21740  rsp: 0x00007ff7b8a21740
   r8: 0x00007ff84d65b488   r9: 0x0000000000000000  r10: 0x0000000115dbe6ac  r11: 0x0000000000000247
  r12: 0x0000000000000000  r13: 0x00000001074e3c0c  r14: 0x0000000000000040  r15: 0x00000001074e3a53
  rip: 0x00007ff80be2d94e  rfl: 0x0000000000010206  cr2: 0x0000000000000040
  
Logical CPU:     2
Error Code:      0x00000004 (no mapping for user data read)
Trap Number:     14

Thread 0 instruction stream:
  48 89 f3 49 89 fe 48 8d-3d e9 06 83 41 be 00 00  H..I..H.=...A...
  05 00 e8 4f 80 00 00 b8-00 01 00 00 48 8d 0d df  ...O........H...
  06 83 41 48 83 3c c1 00-74 12 48 ff c0 48 3d 00  ..AH.<..t.H..H=.
  03 00 00 75 ee bb 23 00-00 00 eb 0c 48 f7 d3 48  ...u..#.....H..H
  89 1c c1 49 89 06 31 db-48 8d 3d a7 06 83 41 e8  ...I..1.H.=...A.
  18 80 00 00 89 d8 5b 41-5e 5d c3 90 55 48 89 e5  ......[A^]..UH..
 [48]81 3f 5a 54 55 4d 75-73 8b 47 0c 89 c1 81 e1  H.?ZTUMus.G.....	<==
  c0 01 00 00 83 f9 40 74-6b 0f ba e0 0e 72 6d 48  [email protected]
  8d 57 27 48 83 e2 f8 48-8b 0a f6 c1 02 75 45 4c  .W'H...H.....uEL
  8d 57 1f 49 83 e2 f8 65-4c 8b 04 25 f8 ff ff ff  .W.I...eL..%....
  49 b9 00 00 00 00 ff ff-ff ff 48 89 ce f6 c1 02  I.........H.....
  75 22 4c 21 ce 89 c8 48-09 f0 83 c9 02 48 09 f1  u"L!...H.....H..

Binary Images:
    0x7ff80be2c000 -     0x7ff80be37fff libsystem_pthread.dylib (*) <6c7561b4-4b92-3f45-921e-abe669299844> /usr/lib/system/libsystem_pthread.dylib
    0x7ff80bcfd000 -     0x7ff80bd85fff libsystem_c.dylib (*) <e58814cc-dcb7-35a5-badc-e367ed3ac207> /usr/lib/system/libsystem_c.dylib
       0x1074dc000 -        0x1074e3fff tldr (*) <5e171f9c-478a-3c66-9fbb-08c96eac8e7b> /usr/local/Cellar/tldr/1.4.2/bin/tldr
       0x115d3e000 -        0x115da9fff dyld (*) <cef5a27a-d50b-3020-af03-1734b19bc8c5> /usr/lib/dyld
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=398.4M resident=0K(0%) swapped_out_or_unallocated=398.4M(100%)
Writable regions: Total=531.3M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=531.3M(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Activity Tracing                   256K        1 
Kernel Alloc Once                    8K        1 
MALLOC                           139.1M       12 
MALLOC guard page                   16K        4 
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
STACK GUARD                       56.0M        1 
Stack                             8192K        1 
VM_ALLOCATE                          8K        2 
__DATA                            2402K      136 
__DATA_CONST                      5238K       89 
__DATA_DIRTY                       209K       51 
__LINKEDIT                       312.5M        8 
__OBJC_RO                         81.8M        1 
__OBJC_RW                         3136K        2 
__TEXT                            85.9M      150 
__UNICODE                          588K        1 
dyld private memory               1024K        1 
shared memory                       12K        2 
===========                     =======  ======= 
TOTAL                              1.1G      464 
TOTAL, minus reserved VM space   695.9M      464 

tldr-2021-12-21-194826.ips.zip

Version information looks wrong

Reproduction Rate

This happens every time.

Steps to Reproduce

Run tldr -v

Result

Xxxxs-MacBook-Pro:~ $ tldr -v
tldr v1.3.0 (v1.3.0)
Copyright (C) 2016 Arvid Gerstmann
Source available at https://github.com/tldr-pages/tldr-c-client

Expected Result

Xxxxs-MacBook-Pro:~ $ tldr -v
tldr v1.4.1 (v1.4.1)
Copyright (C) 2016-2021 Arvid Gerstmann
Source available at https://github.com/tldr-pages/tldr-c-client

Although I am not sure why the version number is displayed twice, to be honest.

Additional Information

I am using macOS Catalina (10.15.7) and Homebrew (3.3.3) to install, here's an example, showing 1.4.1 is downloaded but it displays 1.3.0:

Xxxxs-MacBook-Pro:~ $ brew install tldr
==> Downloading https://ghcr.io/v2/homebrew/core/tldr/manifests/1.4.1
Already downloaded: /Users/xxxxx/Library/Caches/Homebrew/downloads/7d2e739c6a1c2d56d0a50d3ef21d580d8248fd9e45ed004b29b473047d617d4c--tldr-1.4.1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/tldr/blobs/sha256:6cfce860468cd9b2aa4a1db7d03cc989421666cdc2b55a041e1eb5f032fb2e80
Already downloaded: /Users/xxxxx/Library/Caches/Homebrew/downloads/166628835251bdf52acd52f3511292aa64930b2a8459d9e503f161255bda95e5--tldr--1.4.1.catalina.bottle.tar.gz
==> Pouring tldr--1.4.1.catalina.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
🍺  /usr/local/Cellar/tldr/1.4.1: 10 files, 82.1KB
Xxxxs-MacBook-Pro:~ $ tldr -v
tldr v1.3.0 (v1.3.0)
Copyright (C) 2016 Arvid Gerstmann
Source available at https://github.com/tldr-pages/tldr-c-client
Xxxxs-MacBook-Pro:~ $ 

"tldr --update" shows message "Local data is older than two weeks, use --update to update it."

Reproduction Rate

everytime

Steps to Reproduce

Install tldr.
Wait more than 2 weeks
perform Local data is older than two weeks, perform "tldr --update"

Result

Shows error "Local data is older than two weeks, use --update to update it."

Expected Result

Why is it showing me an error to update, when I just passed the update flag? Shouldnt show this error message.

Additional Information

~ $tldr --version
tldr v1.3.0 (v1.3.0)
Copyright (C) 2016 Arvid Gerstmann
Source available at https://github.com/tldr-pages/tldr-cpp-client

ro locale not recognised / read from pages.ro

Reproduction Rate

<How often could you reproduce this issue, how often do you tried?>

every time

Steps to Reproduce

  • set locale to the Romanian language
    sudo apt install tldr
    tldr todoist

Result

<What is the result of this?>

todoist page is shown in English

Expected Result

<What is the expected result?>

tldr should show the Romanian page

Additional Information

<Which version? Which operating system? Any other information?>

latest, Raspbian OS, Linux raspberry 5.10.52-v7+ #1441 SMP

C++ style comments are not allowed in ISO C90

It seems that some gcc compiles does not accept "//" for comment, when -ansi flag is turned on in Makefile.

make PREFIX=/mnt/home/jchen/.linuxbrew/Cellar/tldr/1.3.0_2 install
Last 15 lines from /mnt/home/jchen/.cache/Homebrew/Logs/tldr/01.make:
PREFIX=/mnt/home/jchen/.linuxbrew/Cellar/tldr/1.3.0_2
install

CC src/local.c
CC src/net.c
CC src/parser.c
CC src/tldr.c
CC src/utils.c
In file included from src/utils.c:12:0:
/mnt/home/jchen/.linuxbrew/Cellar/libzip/1.5.2_1/include/zip.h:261:1: error: C++ style comments are not allowed in ISO C90
// clang-format on

Improve verbosity of updating

I think it's worth mentioning to add more verbosity to --update flag since we could not see anything in this first place. How about:

  • How many data will be updated?
  • Which ones are changed?
  • Changed by whom?
  • From which commit to where?
  • etc.
$ tldr --update
# Nothing writes here

"tldr --update" failed due to "Error: Download File: https://github.com/tldr-pages/tldr/archive/master.zip"

Reproduction Rate

<How often could you reproduce this issue, how often do you tried?>
Every time I run tldr --update.

Steps to Reproduce

Run `tldr -- update`

Result

<What is the result of this?>

Error: Downloading File: https://github.com/tldr-pages/tldr/archive/master.zip

Expected Result

<What is the expected result?>
Update local database?

Additional Information

<Which version? Which operating system? Any other information?>

  • MacOS High Sierra; used brew install tldr --HEAD to install. #38 mentioned install HEAD version can solve this issue, which does work for me.

  • I am able to download that master.zip file using wget.

New completion for fish

I create new autocompletion for fish shell.

complete -c tldr -s h -l help        -d "show this help message" -f
complete -c tldr -s v -l version     -d "show program's version number" -f
complete -c tldr -s u -l update      -d "Update the local cache of pages" -f
complete -c tldr -s p -l platform    -d "Override the operating system" -xa "linux osx sunos windows common"
complete -c tldr -s l -l list        -d "List all commands in the cache" -f
complete -c tldr -s s -l source      -d "Override the default page source" -r
complete -c tldr -s c -l color       -d "Override color stripping" -f
complete -c tldr -s r -l render      -d "Render local markdown files" -r
complete -c tldr -s l -l language    -d "Override the default language" -f
complete -c tldr -s m -l markdown    -d "Just print the plain page file" -f
complete -c tldr -l print-completion -d "Print shell completion script" -xa "bash zsh tcsh"

function __tldr_commands
    tldr --list | string replace -a -r "', '" "\n" | string replace -a -r "\['|'\]" ""
end

complete -f -c tldr -a "(__tldr_commands)"

Can you add it into /usr/share/fish/vendor_completions.d/tldr.fish ?

Local stack overflow error

Should check sum size before memcpy

while (optind < argc) {
            if (sum >= 4096)
                exit(EXIT_FAILURE);

            len = strlen(argv[optind]);
            memcpy(buf + sum, argv[optind], len);
            memcpy(buf + sum + len, "-", 1);
            sum += len + 1;
            optind++;
        }

Maybe

while (optind < argc) {
            len = strlen(argv[optind]);
             if (sum+len >= 4096)
                exit(EXIT_FAILURE);
            memcpy(buf + sum, argv[optind], len);
            memcpy(buf + sum + len, "-", 1);
            sum += len + 1;
            optind++;
        }

Add new/blank line at end of output?

I noticed a new/blank line is added before output for clarity.
So I propose that one be added afterwards for the same reason.

current:

MacBookPro-Matt:~ matt$ tldr shasum

shasum

Calculate or check cryptographic SHA checksums.

- Calculate the SHA1 checksum for a file:
    shasum filename

- Calculate the SHA256 checksum for a file:
    shasum --algorithm 256 filename

- Calculate the SHA512 checksum for multiple files:
    shasum --algorithm 512 filename1 filename2

- Check a file with a list of sums against the directory's files:
    shasum --check list_file

- Calculate the SHA1 checksum from stdin:
    somecommand | shasum
MacBookPro-Matt:~ matt$

proposed:

MacBookPro-Matt:~ matt$ tldr shasum

shasum

Calculate or check cryptographic SHA checksums.

- Calculate the SHA1 checksum for a file:
    shasum filename

- Calculate the SHA256 checksum for a file:
    shasum --algorithm 256 filename

- Calculate the SHA512 checksum for multiple files:
    shasum --algorithm 512 filename1 filename2

- Check a file with a list of sums against the directory's files:
    shasum --check list_file

- Calculate the SHA1 checksum from stdin:
    somecommand | shasum

MacBookPro-Matt:~ matt$

config:

tldr v1.3.0 (v1.3.0)
Copyright (C) 2016 Arvid Gerstmann
Source available at https://github.com/tldr-pages/tldr-cpp-client

[Feature request] add `--platform=all` option value

Problem

Whatever host development system tldr is installed on, I'd prefer to always have the full range of pages searchable by default regardless of platform. At the moment it is only possible to search entries on another platform by selecting that platform explicitly, since this tool defaults to auto-detection:

tldr --platform=linux ufw

Very often (and until I looked it up), I had forgot to do this and thought the entry was undefined. Furthermore, it is not possible to search through all platforms at once – a user would have to alter the command each time.

Potential solution

I propose that the platform option is updated to read all as a value (or alternatively a comma separated list of existing platforms), which would make the command search through all tldr directories.

With this in place, people could create an alias such as the below and never need to consider platform when using tldr, which would be ideal.

abbr -a tldr 'tldr --platform=all'

Error: Could Not Rename

Reproduction Rate

<How often could you reproduce this issue, how often do you tried?>
always, a lot

Steps to Reproduce

tldr -u

Result

<What is the result of this?>
e.g. Error: Could Not Rename: /tmp/tldrmkhmBO/tldr-master to /home/roger/.tldrc/tldr-master/

Expected Result

<What is the expected result?>
File renamed and moved

Additional Information

<Which version? Which operating system? Any other information?>

tldr v1.3.0 (v1.3.0-12-g0e54281)
Linux Kilo 4.10.1-041001-generic #201702260735 SMP Sun Feb 26 12:36:48 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

/tmp and /home are in separate partitions which maybe why rename reports the following error:

Invalid cross-device link

Segmentation fault

Hello,

using: tldr -list
causes a segmentation fault.
I am using a Mac (osx: 12.1) (tldr v1.4.2 (v1.4.2)) and zsh.

maybe someone can help or explain what I am doing wrong.

Suggestion: Add an env variable to specify cache directory

Hello, and thanks for the cli, it's very useful!

Having an env variable like TLDR_CACHE_DIR would be very useful to control what's written in the home.

Since it is only a cache, users should expect to be safely able to remove it.
However, they can be hesitant when it's another dotfile in their home dir.

Feature request: auto-update tldr pages

Every two weeks, I get the message
Local data is older than two weeks, use --update to update it.

I'd like TLDR to just auto-update when it needs to.

I think this could be easily/simply implemented by giving users the option to set an environment variable, e.g. TLDR_AUTOUPDATE. If this variable is set, we could have check_localdate automatically call update_localdb if necessary. None of this would impact users who do not set the environment variable.

I'd be happy to work on it and submit a PR if people think it's an OK idea.

disable colors

Please add an option to disable color highlighting (or specify a configurable colorscheme).

Windows Support

I don't use Windows, neither do I have a valid Windows installation. Would be nice if someone could make tldr work natively on Windows.

Bash on Ubuntu on Windows - TLDR update command fails

Reproduction Rate

I could reproduce the issue each time I tried to update TLDR local database.

Steps to Reproduce

  1. Install Windows Subsystem for Linux.
  2. Install Ubuntu on Windows.
  3. Run Bash on Ubuntu on Windows.
  4. Install linuxbrew. There is installation instruction on http://linuxbrew.sh.
  5. Install TLDR C++ client: brew update and brew install tldr.
  6. Try to update TLDR local database: tldr --update.

Result

$ tldr --update
Error: Could Not Rename: /tmp/tldrElmG3W/tldr-master to /mnt/d/joachim/.tldrc/tldr-master/

Expected Result

Update of TLDR local database.

Additional Information

Windows Subsystem for Linux, Bash on Ubuntu on Windows
TLDR C++ has been installed with linuxbrew

I have tried to update TLDR as superuser:

$ sudo tldr --update
[sudo] password for joachim:

There is no error message when I update TLDR as superuser but I'm still unable to print any TLDR page. Each attempt ends with This page doesn't exist yet! error message.

Do not invoke update_localdb if provide with an option flag.

Could we provide an option that:
While the option flag is on, when an command is not fount, do not invoke update_localdb.
So I could manually update my cache if I want to.

It would be really convenient in the under circumstances:
1 poor network situation.
2 trying to get several commands instruction.

then it would be possible for:
Manually update cache before trying out several command,
instead of having to invoke update_localdb every time if the command is not found on localdb
since poor network situation.

~/g/p/C/u/u/intro > time tldr lss
This page doesn't exist yet!
Submit new pages here: https://github.com/tldr-pages/tldr
tldr lss  0.02s user 0.01s system 0% cpu 4.425 total

Make fails to find libzip and curl when using /opt/homebrew

Steps to Reproduce

  1. Install homebrew to /opt/homebrew (which is the default for the M1 machines)
  2. Run make
  3. See compilation error

Result

<What is the result of this?>

$ make
CC src/tldr.c
LD tldr
ld: warning: directory not found for option '-L/usr/local/opt/curl/lib'
ld: warning: directory not found for option '-L/usr/local/opt/libzip/lib'
ld: library not found for -lzip
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [tldr] Error 1

Expected Result

Compilation passes.

Additional Information

This diff fixes it at the expense of breaking other platforms:

diff --git a/Makefile b/Makefile
index bda31e8..e958f7d 100644
--- a/Makefile
+++ b/Makefile
@@ -48,14 +48,16 @@ ALL_CPPFLAGS	+= -D_GNU_SOURCE
 ALL_CPPFLAGS	+= $(shell pkg-config --cflags libzip)
 ALL_CPPFLAGS	+= -I/usr/include
 ALL_CPPFLAGS	+= -I/usr/local/include
-ALL_CPPFLAGS	+= -I/usr/local/opt/curl/include
-ALL_CPPFLAGS	+= -I/usr/local/opt/libzip/include
+ALL_CPPFLAGS  += -I/opt/homebrew/include
+ALL_CPPFLAGS	+= -I/opt/homebrew/opt/curl/include
+ALL_CPPFLAGS	+= -I/opt/homebrew/opt/libzip/include

 # Linker Flags
 ALL_LDFLAGS		:= $(LDFLAGS) -L/usr/lib
 ALL_LDFLAGS		+= -L/usr/local/lib
-ALL_LDFLAGS		+= -L/usr/local/opt/curl/lib
-ALL_LDFLAGS		+= -L/usr/local/opt/libzip/lib
+ALL_LDFLAGS		+= -L/opt/homebrew/lib
+ALL_LDFLAGS		+= -L/opt/homebrew/opt/curl/lib
+ALL_LDFLAGS		+= -L/opt/homebrew/opt/libzip/lib
 ALL_LDLIBS		:= -lc -lm -lcurl -lzip

Leaving the old directories I think works, but it does also emit a warning when running make about those directories not existing. Not sure what best practices around make are with regards to maybe optionally including directories if they exist or not, or if it's standard to ignore "missing directory" warnings.

Display first execution slowness reason

Reproduction Rate

Always?

Steps to Reproduce

When using tldr for the first time.

Result

First start is REALLY slow. After it works like a charm.

Expected Result

I guess initial data are downloaded/unzipped/whatever
but I was thinking I was using the (slow?) Python client.

I realized after than homebrew was already installing this client by default and consecutive executions were really fast.

So why not display an initial message explaining that we're already using an optimized client and that only first start is slow?

Additional Information

➜  ~ $ tldr --version
tldr v1.3.0 (v1.3.0)
Copyright (C) 2016 Arvid Gerstmann
Source available at https://github.com/tldr-pages/tldr-cpp-client

This version is slower than the Python one

Reproduction Rate

I could reproduce the issue every time I use tldr

Steps to Reproduce

  1. Install the C client for tldr
    • in my case, brew install tldr
  2. Install the Python client for tldr
    • in my case, pip install tldr
  3. Run both tldrs once, to update indices
  4. Run repeat 5 time tldr grep > /dev/null

Result

C version is about 5 times slower than the Python one

# C version
$ repeat 5 time tldr grep > /dev/null
tldr grep > /dev/null  0,06s user 0,01s system 4% cpu 1,610 total
tldr grep > /dev/null  0,06s user 0,01s system 11% cpu 0,609 total
tldr grep > /dev/null  0,06s user 0,01s system 15% cpu 0,476 total
tldr grep > /dev/null  0,06s user 0,01s system 19% cpu 0,369 total
tldr grep > /dev/null  0,06s user 0,01s system 15% cpu 0,469 total
# average: 0,706
# Python version
$ repeat 5 time ./.venv/bin/tldr grep > /dev/null
./.venv/bin/tldr grep > /dev/null  0,11s user 0,04s system 66% cpu 0,224 total
./.venv/bin/tldr grep > /dev/null  0,08s user 0,02s system 96% cpu 0,103 total
./.venv/bin/tldr grep > /dev/null  0,08s user 0,02s system 95% cpu 0,101 total
./.venv/bin/tldr grep > /dev/null  0,08s user 0,02s system 95% cpu 0,107 total
./.venv/bin/tldr grep > /dev/null  0,09s user 0,02s system 96% cpu 0,120 total
# average: 0,131

Expected Result

I expected, that the C version would be faster than the Python one, since C is a compiled language.

Additional Information

I am using macOS 10.15.7

Add missing commands

Excerpt from the node-client's README:

  • tldr --linux <command> show command page for Linux
  • tldr --osx <command> show command page for OSX
  • tldr --sunos <command> show command page for SunOS
  • tldr --list show all pages for current platform
  • tldr --list-all show all available pages

Upon not receiving any input for the tldr command, it should invoke itself

if the user types in just tldr only to have no output generated. We could output something like this:

Usage: tldr [OPTIONS] COMMAND [ARGS]...

  A python client for tldr: simplified and community-driven
  man pages.

Options:
  -V, --version  Show the version and exit.
  -h, --help     Show this message and exit.

Commands:
  find    Find the command usage.
  init    Init config file.
  update  Update to the latest pages.

This is what the python client does, or we could simply invoke tldr tldr

provide --platform option

I know there are other clients to choose from but I just want to leave it here as an idea as this is the default clients.

sometimes I want to look up tldr for a different os or see the difference. in this case the bash version comes in handy:

https://github.com/raylee/tldr

USAGE: tldr [options] <command>

[options]
    -l, --list:      show all available pages
    -p, --platform:  show page from specific platform rather than autodetecting
    -u, --update:    update, force retrieving latest copies of locally cached files
    -h, -?, --help:  this help overview

Maintain local index

I'm sure this feature is on the horizon, is this the right time to startup this discussion?

[Feature request] Add download prompt and option to toggle it off

Search a nonexisting command could take 5 seconds, like tldr u
This could be worse in some poor networks.

https://github.com/tldr-pages/tldr-cpp-client/blob/9b23d268548d3324581997c07df453542b302d51/src/tldr.c#L160-L164
https://github.com/tldr-pages/tldr-cpp-client/blob/9b23d268548d3324581997c07df453542b302d51/src/parser.c#L214-L221

Expect

  1. Add prompt for friendly
fprintf(stderr, "Searching INPUT in URL...\n");
  1. option to turn search function on/off

Error when try to update local database

❯ tldr --version
tldr v1.3.0 (v1.3.0)
Copyright (C) 2016 Arvid Gerstmann
Source available at https://github.com/tldr-pages/tldr-c-client

❯ tldr -v -u
main.zip [========================================] 100%
Error: Could Not Rename: /tmp/tldrVRo8lf/tldr to /Users/robinho/.tldrc/tldr/

❯ sw_vers
ProductName:	macOS
ProductVersion:	12.0.1
BuildVersion:	21A559

Find version without using git

When Homebrew installs a package, it removes the .git folder to make sure all builds are reproducible. When I run make, an error is printed:

fatal: Not a git repository (or any of the parent directories): .git

from the git describe command in the Makefile. It would be great if there was also a way to build the project and get the version without needing git. I'm not quite sure what the best approach is here.

Problematic default colors

I get this output, here for tldr wc, on iTerm2/OSX:

...

Maybe my console's color scheme is at fault, but since there doesn't seem to be a way to change the colors tldr is using (unlike the node client, but that one doesn't work at all) and there is no documentation about what color set is uses, I don't know how to fix this on my end.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.