luvit / lit

Toolkit for developing, sharing, and running luvit/lua programs and libraries.
http://lit.luvit.io/
Apache License 2.0
245 stars 58 forks source link

Init command. Closes #124 #126

Closed james2doyle closed 8 years ago

james2doyle commented 9 years ago

preview

I think I have got this down now. I'll explain some features:

This is my first PR that is Lua based, so let me know what needs to be fixed or changed before going ahead.

james2doyle commented 9 years ago

Actually, I have a question already. What category in the commands/README do I add the help for this?

rphillips commented 9 years ago

I like the section Package Management, but Tim may have a different opinion.

james2doyle commented 9 years ago

Oh man! I was trying to find a better way but didn't think of the string format template. It's a no brainer now. I'll switch to the string format.

I'll get to this ASAP On Sun, Aug 30, 2015 at 1:01 PM Ryan Phillips notifications@github.com wrote:

I like the section Package Management, but Tim may have a different opinion.

— Reply to this email directly or view it on GitHub https://github.com/luvit/lit/pull/126#issuecomment-136178915.

creationix commented 9 years ago

On Aug 30, 2015 3:01 PM, "Ryan Phillips" notifications@github.com wrote:

I like the section Package Management, but Tim may have a different opinion.

Yep, sounds great.

— Reply to this email directly or view it on GitHub.

creationix commented 9 years ago

My only suggestion is to leave the quotes out of the template and write a simple quoting function to make it a little more robust. Though, we don't need to support all input strings I guess, soo maybe that's less needed here. On Aug 30, 2015 3:56 PM, "James Doyle" notifications@github.com wrote:

Oh man! I was trying to find a better way but didn't think of the string format template. It's a no brainer now. I'll switch to the string format.

I'll get to this ASAP On Sun, Aug 30, 2015 at 1:01 PM Ryan Phillips notifications@github.com wrote:

I like the section Package Management, but Tim may have a different opinion.

— Reply to this email directly or view it on GitHub https://github.com/luvit/lit/pull/126#issuecomment-136178915.

— Reply to this email directly or view it on GitHub https://github.com/luvit/lit/pull/126#issuecomment-136189989.

james2doyle commented 9 years ago

Ok @creationix I think by using the %q format over %s will fix the quoting issue. This is a simple test:

quote example

And here is the description from the Lua.org docs:

To quote an arbitrary string in a secure way, the format function, from the standard string library, offers the option "%q". It surrounds the string with double quotes and properly escapes double quotes, newlines, and some other characters inside the string.

I didn't realize that the %q option existed. No wonder I couldn't find any good Lua string escape functions, they aren't really needed for quotes and string literals.

It doesn't escape $ or backticks, is that a problem here?

creationix commented 9 years ago

Wow, that's great, I never knew about %q. That should work perfectly.

james2doyle commented 8 years ago

I pulled the latest lit and merge it into this branch so it's good to go

creationix commented 8 years ago

Lovely work!

squeek502 commented 8 years ago

Very cool. :+1:

creationix commented 8 years ago

This is in the fresh lit v2.2.13 version. lit update!