Sha256: 98ef3e9b47d94e45e544f754c4272dd5c9c6139e33ae760dcc98d2a38ec9372a

Contents?: true

Size: 512 Bytes

Versions: 4

Compression:

Stored size: 512 Bytes

Contents

module HabiticaCli
  # responsible for adding new todos, tasks, and dailies
  # also for for caching the newly added todo
  module Commands
    def self.add(env, type, text)
      validate_type(type)
      response = env.api.post('tasks/user', type: type, text: text)

      if response.success?
        task = cache_tasks(env, [response.body['data']], type).first
        puts "Added #{task['text']} [#{task['cid']}]"
      else
        puts "Error adding #{text}: #{response.body}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
habitica_cli-1.0.2 lib/habitica_cli/commands/add.rb
habitica_cli-1.0.1 lib/habitica_cli/commands/add.rb
habitica_cli-1.0.0 lib/habitica_cli/commands/add.rb
habitica_cli-0.1.1 lib/habitica_cli/commands/add.rb