wycats / thor
- Source
- Commits
- Network (30)
- Issues (6)
- Downloads (4)
- Wiki (1)
- Graphs
-
Branch:
master
Pledgie Donations
Once activated, we'll place the following badge in your repository's detail box:
A scripting framework that replaces rake and sake — Read more
-
thor has a zero return code when task isn't found
2 comments Created 7 months ago by sconover(I hope this is the right place to submit issues. If it's not I'd be happy to resubmit in the appropriate place)
$ thor task doesnt exist The thor:runner namespace doesn't have a `task' task
$ echo $? 0This is an unsuccessful case, and the return code ought to be nonzero.
Comments
-
Can't figure out why the version number in rubyforge is not even tagged here, tell me if you need any help...
Comments
-
Hi there,
I'd love to use thor in my application, but I'd need it to do a default task when invoked without parameters. ATM it displays the help message in that case.
I was wondering, if there was a way of doing that nicely, since I may have overlooked it.Right now, I'm doing this quick little workaround:
map 'help' => :real_help def help *args list(*args) endwhich will call the list() function when there were no arguments specified and the real_help function, whenever the the help command was given explicitly.
It would be really nice to be able to do something like
map :default => :listor something similar to change the default task more nicely. My solution is quite hacky after all g
Anyways, thanks for this really great program, I'm definitely enjoying it.
Keep up the good work!Comments
-
Hi!
I just noticed:
Thor allows the execution of arbitrary code via any Thorfile. Just run
thor instance_eval "p 12"This will cause thor to call the "instance_eval task" of the Thor object in that Thorfile.
Pretty devastating...
I'd suggest, thor limits the access to builtin functions via tasks, e.g. by using something like this little snippet here I found a while ago:
[http://snippets.dzone.com/posts/show/1873]That would remove all the 'evil' method calls from the thor object.
Greetz!
Comments
Is there a reason why this can be a security issue? If anyone is executing thor, that someone has access the machine, so thor instance_eval "p 12" is the last thing we would be concerned with. ;)
-
Windows platform color codes and path issues.
21 comments Created 2 months ago by gauchedOn windows you need the win32console gem for the color codes to show up.
Also there is an error with the home path.
util.rb 212c212 < File.join(user_home, ".thor") --- > File.join(user_home, ".thor").gsub('\\', '/')Comments
Yeah, I'm going to write some code that only uses the color on windows if win32console is enabled. And I'll fix the other issue asap. Thanks :)
i have win32console installed in my 1.9.1p243 (mingw) from http://rubyinstaller.org and cmd.exe still doesn't understand Thor's colorful language.
I had to implement the following brute force patch but it would be nice to see color if win32console is installed. That said, I don't think a hard dependency on win32console is appropriate as falling back on the Basic shell is OK.
diff --git a/lib/thor/shell.rb b/lib/thor/shell.rb index 0d3f4d5..6fe4273 100644 --- a/lib/thor/shell.rb +++ b/lib/thor/shell.rb @@ -1,11 +1,13 @@ require 'thor/shell/color' +require 'rbconfig' class Thor module Base # Returns the shell used in all Thor classes. Default to color one. # def self.shell - @shell ||= Thor::Shell::Color + # TODO win32console patch if project will accept a soft dependency + @shell ||= RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? Thor::Shell::Basic : Thor::Shell::Color end # Sets the shell used in all Thor classes.Sounds great.
FYI, last time I checked, the
Console.soinstalled withgem install win32consolewas only linked againstmsvcrt-ruby18.dllwhich is a problem for 1.9.1 users and may be the root of http://github.com/luislavena/win32console/issues#issue/1I don't know whether the fix Luis mentions addresses the 1.9.1 issue or not, but hopefully the fix will be a fat-binary supporting mswin and mingw on 1.8 and 1.9.
So I will give up checking for win32console on Windows. By default it will use only Thor::Shell::Basic. :)
And what is exactly the issue with Windows home? I want to represent that in the test suite. What were you getting and what it should return instead?
My main use was on Vista and I was getting the actual ASCII control codes printed out to cmd.exe. I think the same will occur on WinXP.
I'll revert out the patch I listed above and try things out (without win32console) on a Vista and XP machine both running Ruby 1.9.1p243 from http://rubyinstaller.org/ and post results in a bit.
Results from a quick run on Vista Home. Notice the control codes after running
thor -TIf this is different when I try it on XP, I'll post additional results.C:\>type install_validator.thor module RubyInstaller module Extras class Install < Thor namespace :install desc 'validate', 'validate a RubyInstaller installation' def validate say 'Validating...' end end end end C:\>thor -T ←[1m←[34minstall←[0m ------- install:validate # validate a RubyInstaller installationYeah, just committed a fix for it. Now I'm solving File.join(user_home, ".thor") issue, you have a test case for it?
I don't have a spec for my patch to shell.rb.
I'm not familiar with Thor's internals yet, but is there a way to programatically have Thor "say" to a string rather than the shell so we can easily do a regex match in a spec? If yes, let me know and I'll submit a spec for your review.
I don't need a test case, I just need to know what was happening so a patch was needed. It was searching for something like C:\ and it should be C:/ ?
Oh, I see what you're asking. I wasn't the guy reporting the path issue, I just reported the console coloring issue.
I haven't seen the path issue yet, but I also haven't run Thor through the gauntlet either :)
I suspect gauched saw the issue when trying
thor installbut that's only a guess.Could you try installing anything please? You could use this command:
thor install http://github.com/wycats/thor/raw/master/spec/fixtures/task.thor
C:\Users\Jon\Documents>thor install http://github.com/wycats/thor/raw/master/spec/fixtures/task.thor Your Thorfile contains: # module: random class Amazing < Thor desc "describe NAME", "say that someone is amazing" method_options :forcefully => :boolean def describe(name, opts) ret = "#{name} is amazing" puts opts["forcefully"] ? ret.upcase : ret end end Do you wish to continue [y/N]? y Storing thor file in your system repositorywhich created a C:\Users\Jon.thor directory containing a .yml file and the SHA1 named thor file.
C:\Users\Jon\Documents>thor installed Modules Namespaces ------- ---------- random amazing amazing ------- amazing:describe NAME [--forcefully] # say that someone is amazingtrying multiple ways to uninstall
C:\Users\Jon\Documents>thor uninstall amazing Can't find module 'amazing' C:\Users\Jon\Documents>thor uninstall random Uninstalling random. Done.removed files from C:\Users\Jon.thor and left a semi-empty
thor.ymlfile containing a single line--- {}\r\n\r\nC:\Users\Jon\Documents>thor installed No Thor tasks availableI just looked over the latest mod to shell.rb in which
@shell ||= if RUBY_PLATFORM =~ /mswin|mingw/Need to check that this works properly with JRuby running on Windows as JRuby returns
javaforputs RUBY_PLATFORM
Just did the following quick test on JRuby 1.3.1
C:\Users\Jon\Documents\RubyDev\rubyinstaller-trunk\extras>"C:\jruby\bin\jruby" -I"c:/Users/Jon/Documents/RubyDev/thor-trunk/bin" -I"C:/Users/Jon/Documents/RubyDev/thor-trunk/lib" c:\Users\Jon\Documents\RubyDev\thor-trunk\bin\thor -T WARNING: unable to load thorfile "C:/Users/Jon/.thor/thor.yml": undefined method `-@' for {}:Hash ←[1m←[34minstall←[0m ------- install:validate # validate a RubyInstaller installationwhich shows the same control code problem.
There's a thread on the JRuby list on this issue of trying to figure out which platform you're running on, the the bottom line is that
RbConfig::CONFIG['host_os'] =~ /mswin|mingw/appears to be the most reliable solution so far.http://groups.google.com/group/jruby-users/browse_thread/thread/ca1f0cf3c1a18912/987155124e9501fe
-
It would be great to define dependencies between options, such as:
class_option :generate_migration, :type => :boolean
class_option :table, :type => :string :desc => 'Database table in which to operate', :depends => [:generate_migration]
class_option :add_columns, :type => :hash, :desc => 'Columns to add to table', :depends => [:table, :generate_migration]Actually, the last example uses [:table, :generate_migration] just to illustrate, since :table itself depends already on :generate_migrations. Alternatively, :depends could also accept a symbol or string in case of a single dependency.
Additionally, an :assumes option would be also interesting. Suppose this statement:
class_option :table, :type => :string :desc => 'Database table in which to operate', :assumes => {:generate_migration => true}
In this case, passing a table option would assume generate_migration is set to true.
Comments
-
Do not use white by default in invocations status
0 comments Created about 1 month ago by josevalimComments
-
Comments
-
Packaging thor for a Fedora submission and would like to run the specs as part of the build process. The stumbling block seems to be some key files are missing from the gem, eg:
mkent@fortaleza:~/git/thor/spec (master)$ find -type f | grep -v \.rb | grep -v sandbox ./fixtures/bundle/main.thor ./fixtures/doc/README ./fixtures/doc/components/.empty_directory ./fixtures/group.thor ./fixtures/invoke.thor ./fixtures/script.thor ./fixtures/task.thor ./spec.opts
Would it be possible to include these in the gem?
Comments
-
I get this returned to me when asking for the Thor tasks.
[21:22][adamstacoviak@AS-MBP15:~/Code/OS/Thor/Thor-Gem(master)]$ thor -T WARNING: unable to load thorfile "/Users/adamstacoviak/Code/OS/Thor/Thor-Gem/Thorfile": no such file to load -- rdoc/task [21:25][adamstacoviak@AS-MBP15:~/Code/OS/Thor/Thor-Gem(master)]$ gem list rspec *** LOCAL GEMS *** rspec (1.2.9, 1.2.2) rspec-rails (1.2.2)Comments
-
Sometimes the output is:
Runtime options: -p, [--pretend] # Run but do not make any changes -q, [--quiet] # Supress status output -s, [--skip] # Skip files that already exist -f, [--force] # Overwrite files that already existOther times:
Runtime options: -s, [--skip] # Skip files that already exist -p, [--pretend] # Run but do not make any changes -q, [--quiet] # Supress status output -f, [--force] # Overwrite files that already existComments





Good call. Let's fix this ASAP.
Fixed!