- Notifications
You must be signed in to change notification settings - Fork 341
implements feature to list all gists #176
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
Conversation
…: non-authed user}
👍 |
@ConradIrwin can you please review this, am I missing something ? |
lib/gist.rb Outdated
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.
This should raise a Gist::Error
so that it exits with exit status 1: https://github.com/defunkt/gist/blob/master/bin/gist#L164
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.
actually this block executes when user is not authenticated and trying to use it like a authed user
gist --list
(without providing username)
So, this is just a message to user for help. I can add exit 1
explicitly if you say.
but when I put raise Error, MESSAGE
here. It results in
/var/lib/gems/1.9.1/gems/gist-4.2.1/lib/gist.rb:190:in `pretty_gist': Bad credentials (RuntimeError) from /var/lib/gems/1.9.1/gems/gist-4.2.1/lib/gist.rb:141:in `list_gist' from /var/lib/gems/1.9.1/gems/gist-4.2.1/bin/gist:114:in `block (2 levels) in <top (required)>' from /usr/lib/ruby/1.9.1/optparse.rb:1391:in `call' from /usr/lib/ruby/1.9.1/optparse.rb:1391:in `block in parse_in_order' from /usr/lib/ruby/1.9.1/optparse.rb:1347:in `catch' from /usr/lib/ruby/1.9.1/optparse.rb:1347:in `parse_in_order' from /usr/lib/ruby/1.9.1/optparse.rb:1341:in `order!' from /usr/lib/ruby/1.9.1/optparse.rb:1432:in `permute!' from /usr/lib/ruby/1.9.1/optparse.rb:1453:in `parse!' from /var/lib/gems/1.9.1/gems/gist-4.2.1/bin/gist:13:in `<top (required)>' from /usr/local/bin/gist:23:in `load' from /usr/local/bin/gist:23:in `<main>'
which does not look fine.
can you comment here, please. @ConradIrwin
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.
Oh, I see the problem. You should do something like:
opts.on("-l", "--list [USER]", "List all gists for user") do |user| options[:list] = user end
And then inside the begin/rescue/end on https://github.com/defunkt/gist/blob/master/bin/gist#L126 you can do:
if options.key? :list if options[:list] Gist.list_gists(options[:list]) else Gist.list_gists end else # do normal gist stuff here end
The advantage of raising an error is that then people can use gist as a library in their applications; if we just exit
in the middle of running Gist.list_gists
, then it's harder for other programmers to handle the error.
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.
cool, you are a helpful person 😄
changed it in similar manner as you suggested. all set 👍
Hi @pravj! Sorry for the delay. I've added some feedback in-line, please let me know if you need more help. This will be an awesome feature to have! |
> shows file name instead of description > change optparse block in bin/gist
Hi @ConradIrwin, I made some changes as you suggested and commented where I need to discuss. |
lib/gist.rb Outdated
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.
This needs a rescue nil
(as above) to handle the case where that file doesn't exist. It might be nicer to refactor this into a method:
def auth_token @auth_token ||= File.read(auth_token_file) rescue "" end
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.
yeah I noticed this, thanks.
added a new method auth_token
which use rescue
and returns access token string value or nil
if, file is not there.
even changed some part of multi_gist
method, which now uses this new method to collect access token.
this is also working fine 👍
@pravj Awesome! I think this is getting close :). |
> removed header lines for public and private gists.
> now exceptions in middle of execution goes to 'rescue' and exit with status 1
> new method 'auth_token' returns access token string, if it exists or returns 'nil' if access token file is not there.
Yo @ConradIrwin, I think I have fixed everything, you asked me. and call me if you have any thing else, that you want me to do 😄 |
Merged and released! I made a few tidy-up commits which you can look at if you like, but you did all the hard work :). Thanks for being patient, and for your excellent contribution! I'm going to be using this all the time. |
thanks, I'm feeling good now 😄 |
@ConradIrwin Btw in your recent commit 90fb58f |
it works in this way :
gist --list
orgist -l
: will check if user is authenticated or notit also takes one
optional parameter
asusername
gist --list abhshkdz
will list all public gists of userabhshkdz
, it resulted :@ConradIrwin @rking can you please see this, as it was discussed in issue #168 also
tell me if I need to do anything else ✋