Class: Wheneverd::CLI::Init
- Inherits:
-
Wheneverd::CLI
- Object
- Clamp::Command
- Wheneverd::CLI
- Wheneverd::CLI::Init
- Defined in:
- lib/wheneverd/cli/init.rb
Overview
Implements wheneverd init to create a schedule template file.
Constant Summary collapse
- TEMPLATE =
<<~RUBY # frozen_string_literal: true # This file is evaluated as Ruby. # # Supported `every` period forms: # - interval strings: "5m", "1h", "2d" # - duration objects: 1.day, 2.hours # - symbol shortcuts: :hour, :day, :month, :year # - day selectors: :monday..:sunday, :weekday, :weekend (multiple day symbols supported) # - cron strings (5 fields): "0 0 27-31 * *" every "5m" do command "echo hello" end every 1.day, at: "4:30 am" do command "echo four_thirty" end every 1.day, at: ["4:30 am", "6:00 pm"] do command "echo twice_daily" end every :hour do command ["echo", "hello world"] end every :sunday, at: "12pm" do command "echo weekly" end every :tuesday, :wednesday, at: "12pm" do command "echo midweek" end every :day, at: "12:15" do shell "echo hello | sed -e s/hello/hi/" end every "0 0 27-31 * *" do command "echo raw_cron" end RUBY
Instance Method Summary collapse
Methods inherited from Wheneverd::CLI
#handle_error, #identifier_value, #load_schedule
Instance Method Details
#execute ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/wheneverd/cli/init.rb', line 55 def execute path = File.(schedule) return 1 if refuse_overwrite_without_force?(path) existed = write_template(path) puts "#{existed ? 'Overwrote' : 'Wrote'} schedule template to #{path}" 0 rescue StandardError => e handle_error(e) end |