isacikgoz / tldr

fast and interactive tldr client written with go
https://isacikgoz.me/tldr/
MIT License
1.36k stars 48 forks source link

Operating system not recognized #11

Closed target111 closed 5 years ago

target111 commented 5 years ago

Tool doesn't work in termux, says operating system not recognized. I don't see any reasons why it shouldn't work and unfortunately there's no flag to disable this check.

isacikgoz commented 5 years ago

Hey @target111 , thanks for the feedback I will be looking into this. Which OS do you use? As you said we can add a flag to ignore OS recognition.

target111 commented 5 years ago

I'm using termux which is basically an Android terminal emulator and Linux environment app so it's not actually on OS but still I think this program should run fine on it with without modifications.

One thing that should be noted though is that termux does not follow Filesystem Hierarchy Standard unlike majority of Linux distributions. You cannot find directories like /bin, /etc, /usr, /tmp and others at usual location. If this program tries to save any data in one of those locations it will not work unless patched before with correct paths.

https://wiki.termux.com/wiki/Differences_from_Linux

https://termux.com

isacikgoz commented 5 years ago

I think the OS does not seem to be any of windows, linux, darwin or solaris. I may found some kind of a workaround.

Also, the code requires os.Getenv("HOME") + "/.local/share" directory to clone tldr-pages repository. As far as I read the docs, termux indeed has a $HOME variable so it won't be the problem. The problem is, code does not know where it should clone the repo.

The problem is, tldr-pages are also linked to OS, as you can see here. I lookup for the page according to your OS. If we skip the "clone directory problem" we will still got issues for which page to find since there will be no page for Android. This can be handled by setting an environment variable though. You can set export TLDR_OS=linux.

But first it is needed to add support to clone repository in an Android OS. To do this, I need an android env. Currently I don't have any, but if you can help me we can try something:

You will need to add a new case in this function:

https://github.com/isacikgoz/tldr/blob/daae0ae0bed71cefaa99e567dfcb853dc4b50003/pkg/config/source.go#L72

which will be

    case "android":
            d = os.Getenv("HOME") + "/.local/share" //make sure this dir actually exists.

Can you compile and test it?

target111 commented 5 years ago

Sorry for the delayed reply. I tried making the changes mentioned above and I can confirm it indeed works. The $HOME var is present as is the .local/share directory. Only problem would be that you're checking for platform in two different places. Once in source.go and once in configurer.go so adding that switch case only accounts for one of those files and you still have to set the TLDR_OS var to linux.

isacikgoz commented 5 years ago

Hello @target111 , I added andorid os to source.go file, so that you can use it with setting the env variable. It is now realesed with v0.6.1