Module: StandupMD::Cli::Helpers

Included in:
StandupMD::Cli
Defined in:
lib/standup_md/cli/helpers.rb

Overview

Helpers for CLI commands and option handling.

Instance Method Summary collapse

Instance Method Details

#post(entry) ⇒ StandupMD::Post::Result?

Post an entry to the configured chat adapter.

Parameters:

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/standup_md/cli/helpers.rb', line 29

def post(entry)
  return puts "No record found for #{config.cli.date}" if entry.nil?

  result = StandupMD::Post.post(
    entry,
    adapter: config.cli.post_adapter,
    channel: config.cli.post_channel,
    config: config
  )
  puts "Could not post to #{result.adapter}: #{result.error}" if result.failure?
  result
end

Print an entry to the command line.

Parameters:

Returns:

  • (nil)


17
18
19
20
21
# File 'lib/standup_md/cli/helpers.rb', line 17

def print(entry)
  return puts "No record found for #{config.cli.date}" if entry.nil?

  $stdout.print markdown.render_entry(entry)
end