Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

save-file's filename argument should be optional #735

Open
kyrylo opened this Issue · 2 comments

2 participants

Kyrylo Silin Conrad Irwin
Kyrylo Silin
Collaborator

For example, I can't be bothered to type a name of the file when I use save-file command. I want Pry to handle that for me (only if I haven't provided filename as an argument).

[2] pry(main)> def foobar
[2] pry(main)*   :foobar
[2] pry(main)* end  
=> nil
[3] pry(main)> save-file -m foobar
[4] pry(main)> .ls
foobar_method.rb blahblah/
[5] pry(main)> def piyo
[5] pry(main)*   :piyo
[5] pry(main)* end  
=> nil
[6] pry(main)> save-file -m foobar -m piyo
[7] pry(main)> .ls
foo.rb pry_export.rb blahblah/

I think, Pry should choose "intelligent" names (appropriate names for each case, because it can save not only methods :P).

save-file should store files somewhere in ~/pry directory by default. It should be configurable, though. A user should be able to use something like Pry.config.save_file_path to set their custom path.

Conrad Irwin
Owner

This looks pretty good. The $stdin.gets is a bit worrying, but I guess people using pry-remote won't use save-file anyway.

It would seem saner to default Pry.config.save_file_path to the current directory, which would then avoid that problem in the common case (and is probably more "expected"). What do you think?

(/cc @kyrylo)

Kyrylo Silin
Collaborator

Sorry, my fault here. I made a typo in the default save-file path. I meant to write ~/.pry instead of ~/pry. Maybe even ~/.pry/saved_files.

On the other hand, I forgot to mention that in the issue, it could be the current directory as @ConradIrwin said.

I'm not sure, which way I prefer more. Both of them have benefits. @robgleeson, what do you think? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.