-
Notifications
You must be signed in to change notification settings - Fork 40
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
Usage warning #66
Usage warning #66
Conversation
5f3fab4
to
5427ce3
Compare
First of all, lets follow the XDG spec on where to place the icr config file. Second of all, it's not immediately obvious to the user that |
If you're gonna add an annoying message AND go through the trouble of adding this setting file, better make it count and ensure that people will actually read it instead of sending them to some vague location. |
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! Thanks for taking care of it!
src/icr/settings.cr
Outdated
require "yaml" | ||
|
||
class Icr::Settings | ||
PATH = File.expand_path "~/.icr" |
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.
Can we follow the run commands convention with this filename and make it .icrrc
? That would follow other files like .irbrc
, .gemrc
, .bashrc
, .vimrc
, etc... We could easily take advantage of having this file for other settings we might want to add.
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.
rc
stays for run commands
, but this one is actually configuration file..
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.
Right. I was thinking that if this is a flag that gets run when you run icr, and the purpose of the file is to include the flag, it would make sense for it to be a run command. But if we're not going to use it like that, then I guess this is fine.
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.
Please follow the XDG spec here and use the ${XDG_CONFIG_HOME:-~/.config}/icr/
folder.
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.
I've actually never heard of XDG before. What other utilities can I look at that follow this spec so I can see what they are doing?
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.
You'll probably find the spec if you search XDG_CONFIG_HOME
. The idea is to read this environment variable (it's almost never set on a typical system) and fall back to $HOME/.config
.
I'm not sure how I feel about plastering all over "Not a real REPL"... VS saying something like "Not a full featured REPL". Really, we should just work out a plan to make it a full repl 😛 |
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.
I think the XDG spec is a must for any modern application creating config files.
Honestly if you use the XDG spec, you can simplify this to remove the config file and make it a single 0-byte flag file as you have a whole directory to play with. |
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.
I still think this message in its current form is a waste of time. Basically same effect as "RTFM".
It really should be informative to be justified.
How about this: ICR is not a real REPL. It works by building up source code, compiling and re-running all of it after each inputted line. That has side effects, for example: Current time and random numbers change retroactively. |
Hey guys. Thanks for review and valuable comments. @RX14 I know about XDG spec, which was proposed in 2010 and hasn't became a standard (has it?). Moreover, it confuses people on OS X ( @oprypin I like your suggestion regarding warning message. Good point, actually 👍 Will prepare changes during weekend, sorry for delay. |
@veelenga I don't know exactly what you mean by standard but its become very widely used on Linux. About half the applications I use follow the spec, and almost all of the modern ones do. I don't know about how osx handles dot files, but I thought it was the same? |
Right, same way. But as far as I know XDG suggests to use So this becomes a mess. Probably this is a lack of configuration on my system, but I expect it to work properly from scratch 😕 |
@veelenga The advice i've seen is for command-line applications to stick to Perhaps we should create XDG helpers in the stdlib which handle this platform-specificness for you. |
@RX14 Does Haskell have it in stdlib? I think you are referring to xdg-basedir package. It works for me just like you said:
Would love to see similar stuff for Crystal 👍 |
I thought about this at the very beggining. For normal REPL Crystal needs
to support incremental compilation.
Some compiling languages like Haskell or Julia have REPL, so we may take a
look how they do it..
…On Oct 19, 2017 18:14, "Jeremy Woertink" ***@***.***> wrote:
I'm not sure how I feel about plastering all over "Not a real REPL"... VS
saying something like "Not a full featured REPL".
Really, we should just work out a plan to make it a full repl 😛
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#66 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAG7aLEtPJ6lX69SdVfFQedry4J-EAV1ks5st3VOgaJpZM4P-NIL>
.
|
So now: $ rm ~/.config/icr/usage_warning_accepted
remove /Users/_me_/.config/icr/usage_warning_accepted? y $ ./bin/icr
WARNING: ICR is not a full featured REPL.
It works by building up source file, compiling and re-running all of it on each input.
That has side effects:
* Current time and random numbers change retroactively
* Files and network/database connections are reopened on every run
* Running a sleep or benchmark will delay an execution of next inputs
* Unexpected behavior of fibers, channels, shell commands and maybe others
Be careful while running your commands.
You can disable this warning with --disable-usage-warning flag.
icr(0.23.1) > ^D $ ./bin/icr
WARNING: ICR is not a full featured REPL.
It works by building up source file, compiling and re-running all of it on each input.
That has side effects:
* Current time and random numbers change retroactively
* Files and network/database connections are reopened on every run
* Running a sleep or benchmark will delay an execution of next inputs
* Unexpected behavior of fibers, channels, shell commands and maybe others
Be careful while running your commands.
You can disable this warning with --disable-usage-warning flag.
icr(0.23.1) > ^D $ ./bin/icr --disable-usage-warning
Usage warning disabled. Run ICR again to continue. $ ./bin/icr
icr(0.23.1) > ^D $ ls ~/.config/icr/
usage_warning_accepted
|
I like that message better. Saying "Not a full featured REPL". I noticed I have the .config directory too with some stuff in it already, so it's not far fetched throwing some crystal config stuff in there 😅 I think it looks good. |
@RX14 @oprypin @greyblake just need your OK or other feedback :) |
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.
You asked for it 😐
mkdir_p
is the only absolutely necessary change.
OK otherwise.
src/icr/cli.cr
Outdated
def print_usage_warning | ||
puts <<-WARN | ||
WARNING: ICR is not a full featured REPL. | ||
It works by building up source file, compiling and re-running all of it on each input. |
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.
building up a source file
?
src/icr/cli.cr
Outdated
|
||
* Current time and random numbers change retroactively | ||
* Files and network/database connections are reopened on every run | ||
* Running a sleep or benchmark will delay an execution of next inputs |
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.
delay
?an execution
src/icr/cli.cr
Outdated
|
||
unless usage_warning_accepted | ||
parser.on("--disable-usage-warning", "Disable usage warning") do | ||
Dir.mkdir CONFIG_HOME unless Dir.exists? CONFIG_HOME |
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.
mkdir_p
and no need to check for existence
src/icr/cli.cr
Outdated
@@ -32,7 +54,20 @@ OptionParser.parse! do |parser| | |||
parser.on("-r FILE", "--require=FILE", "auto require FILE") do |filename| | |||
libs.push(%{require "#{filename}"}) | |||
end | |||
|
|||
unless usage_warning_accepted | |||
parser.on("--disable-usage-warning", "Disable usage warning") do |
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.
Maybe don't make the application accept a different set of flags depending on some condition? Swap these two lines. Or even remove unless usage_warning_accepted
(see other comment)
src/icr/cli.cr
Outdated
usage_warning_accepted = true | ||
|
||
puts "Usage warning disabled. Run ICR again to continue." | ||
exit 0 |
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.
Why print this message and why quit? Just let it run as normal. It's more predictable. And, well, it's important for scriptable CLI tools to always have a way to not depend on global state. This is not a scriptable tool but still...
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.
No. We shouldn't make it run as normal because it doesn't make it clear that the warning has been permenantly disabled. Install parallel and follow their "citation" procedure to see how it should be done.
Thank you guys for participation and support ;) |
This change is about to warn user regarding usage issues in Readme and while running icr.
Short demo:
should close #65
/cc @jwoertink @greyblake @RX14 @oprypin @martinos