tldr-pages / tldr-c-client

C command-line client for tldr pages
MIT License
299 stars 49 forks source link

More descriptive errors #9

Closed Parth closed 8 years ago

Parth commented 8 years ago

Added the following error if no args are passed in:

➜  src git:(master) ./tldr 
usage: tldr <command>
Which page do you want to see?
try: tldr tldr
➜  src git:(master)

And the following message if the wrong args are passed in:

➜  src git:(master) ./tldr thisdoesntexist 
This page doesn't exist yet!
Submit new pages here: https://github.com/tldr-pages/tldr
➜  src git:(master) 

fixes #7 #8

Let me know what you guys think :smile:

Leandros commented 8 years ago

Please adjust your editor settings to keep the current formatting.

Parth commented 8 years ago

Oh, sorry about that, will fix

Parth commented 8 years ago

@Leandros should be fixed now

Leandros commented 8 years ago

Great. Looks good. One tiny improvement and it's ready for the merge. It's better to use argv[0] instead of hardcoding the tldr command, the executable could be named different.

Parth commented 8 years ago

Good idea, should be fixed now. @Leandros

Leandros commented 8 years ago

You missed the tldr two lines below. ;) I would also rather return EXIT_SUCCESS, since it's not exactly a failure.

Parth commented 8 years ago

Got it! And I checked a few commands and it seems that this type of situation is indeed considered "failure"

➜  src git:(master) git status 
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
➜  src git:(master) echo $?
0
➜  src git:(master) git
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

The most commonly used git commands are:
   add        Add file contents to the index
   bisect     Find by binary search the change that introduced a bug
   branch     List, create, or delete branches
   checkout   Switch branches or restore working tree files
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   fetch      Download objects and refs from another repository
   grep       Print lines matching a pattern
   init       Create an empty Git repository or reinitialize an existing one
   log        Show commit logs
   merge      Join two or more development histories together
   mv         Move or rename a file, a directory, or a symlink
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects
   rebase     Forward-port local commits to the updated upstream head
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index
   show       Show various types of objects
   status     Show the working tree status
   tag        Create, list, delete or verify a tag object signed with GPG

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
➜  src git:(master) echo $?
1
➜  src git:(master) 
Parth commented 8 years ago

I can cite other examples if you'd like

Parth commented 8 years ago

@Leandros

Leandros commented 8 years ago

Please merge the current master thread into your branch, it'll run the travis build. And you should notice the bug in your code, since it won't compile.

Parth commented 8 years ago

Is it all good now?

Leandros commented 8 years ago

Yes. Build passed. Looks good! Merged!

Parth commented 8 years ago

Thanks! :+1: