Skip to main content
Notice removed Canonical answer required by Mike Belyakov
Bounty Ended with Matouš Borák's answer chosen by Mike Belyakov
added 254 characters in body
Source Link
Mike Belyakov
  • 1.4k
  • 1
  • 13
  • 24

I want to know, if the app instance is started by rake, so I tried out catching rake task name in initializers. For example, if I run rake db:migrate I want get db:migrate or something like this. I tried this;

[7] pry(main)> $0 => "spring app | bilet18 | started 3 secs ago | development mode" [8] pry(main)> ARGV => [] [9] pry(main)> Rake.application.top_level_tasks => [] 

but everything is empty.

What can I do that? please help.

UPDATE

if add in Rakefile line like

ENV["RAKE_CURRENT_TASKS"] = Rake.application.top_level_tasks.join(' ') 

then in future you'll be able to catch it in. but this solution is not good for me, I need to catch rake task name earlier

I want to know, if the app instance is started by rake, so I tried out catching rake task name in initializers. For example, if I run rake db:migrate I want get db:migrate or something like this. I tried this;

[7] pry(main)> $0 => "spring app | bilet18 | started 3 secs ago | development mode" [8] pry(main)> ARGV => [] [9] pry(main)> Rake.application.top_level_tasks => [] 

but everything is empty.

What can I do that? please help.

I want to know, if the app instance is started by rake, so I tried out catching rake task name in initializers. For example, if I run rake db:migrate I want get db:migrate or something like this. I tried this;

[7] pry(main)> $0 => "spring app | bilet18 | started 3 secs ago | development mode" [8] pry(main)> ARGV => [] [9] pry(main)> Rake.application.top_level_tasks => [] 

but everything is empty.

What can I do that? please help.

UPDATE

if add in Rakefile line like

ENV["RAKE_CURRENT_TASKS"] = Rake.application.top_level_tasks.join(' ') 

then in future you'll be able to catch it in. but this solution is not good for me, I need to catch rake task name earlier

spelling correction and formatting improved
Source Link
Shiva
  • 12.7k
  • 2
  • 74
  • 91

I want to know, if the app instance is started by rakerake, so i tryedI tried out to catch rake catching rake task name in initializers. For example, if I run rekerake db:migrate I want get db:migrate or something like this. I tryedtried this;

[7] pry(main)> $0 => "spring app | bilet18 | started 3 secs ago | development mode" [8] pry(main)> ARGV => [] [9] pry(main)> Rake.application.top_level_tasks => [] 

but everything is empty.

What can I do that? please help.

I want to know, if the app is started by rake, so i tryed out to catch rake task name in initializers. For example, if I run reke db:migrate I want get db:migrate or something like this. I tryed

[7] pry(main)> $0 => "spring app | bilet18 | started 3 secs ago | development mode" [8] pry(main)> ARGV => [] [9] pry(main)> Rake.application.top_level_tasks => [] 

but everything is empty

I want to know, if the app instance is started by rake, so I tried out catching rake task name in initializers. For example, if I run rake db:migrate I want get db:migrate or something like this. I tried this;

[7] pry(main)> $0 => "spring app | bilet18 | started 3 secs ago | development mode" [8] pry(main)> ARGV => [] [9] pry(main)> Rake.application.top_level_tasks => [] 

but everything is empty.

What can I do that? please help.

Notice added Canonical answer required by Mike Belyakov
Bounty Started worth 50 reputation by Mike Belyakov
added 237 characters in body; edited tags; edited title
Source Link
Mike Belyakov
  • 1.4k
  • 1
  • 13
  • 24

Send to the console new line Get rake task name in CLI toolinitializer

I need automatically answer some questionswant to know, if the app is started by rake, so i tryed out to catch rake task name in CLI modeinitializers. I For example, if I run systemreke 'foo'db:migrate and thenI want get foodb:migrate wait user input ending with enter tap ("\n")or something like this. I tryed

How to realize it?

[7] pry(main)> $0 => "spring app | bilet18 | started 3 secs ago | development mode" [8] pry(main)> ARGV => [] [9] pry(main)> Rake.application.top_level_tasks => [] 

Thank you for your input!but everything is empty

Send to the console new line in CLI tool

I need automatically answer some questions in CLI mode. I run system 'foo' and then foo wait user input ending with enter tap ("\n").

How to realize it?

Thank you for your input!

Get rake task name in initializer

I want to know, if the app is started by rake, so i tryed out to catch rake task name in initializers. For example, if I run reke db:migrate I want get db:migrate or something like this. I tryed

[7] pry(main)> $0 => "spring app | bilet18 | started 3 secs ago | development mode" [8] pry(main)> ARGV => [] [9] pry(main)> Rake.application.top_level_tasks => [] 

but everything is empty

Post Undeleted by Mike Belyakov
Post Deleted by Mike Belyakov
Source Link
Mike Belyakov
  • 1.4k
  • 1
  • 13
  • 24
Loading