<commit_before>require "thor"
require "archangel"
require "date"

class ArchangelCLI < Thor
  class_option :driver, :desc => 'Backend driver to use [file|guardtime]. Defaults to file'
  class_option :username, :desc => 'Guardtime username'
  class_option :password, :desc => '<PASSWORD>'
  class_option :dir, :desc => 'File storage root directory'

  desc "store ID PAYLOAD", "stores PAYLOAD for ID at the current time"
  def store(id, payload)
    storage().store(id, payload, DateTime.now)
  end # store

  desc "fetch ID", "retrieves the PAYLOAD previously stored with ID"
  def fetch(id)
    puts storage().fetch(id)
  end # fetch

  no_commands do
    def storage()
        Archangel.new(
          driver(options[:driver]),
          {
            :root => options[:dir],
            :username => options[:username],
            :password => options[:password]
          }
        )
    end

    def driver(name)
      case name
      when /^file$/i || /^filesystem$/i
        Archangel::Driver::Filesystem
      when /^guardtime$/i
        Archangel::Driver::GuardtimeV2
      when nil<commit_msg>Added ethereum driver option to CLI See https://gist.github.com/cryptogoth/10a98e8078cfd69f7ca892ddbdcf26bc for details of how to get set up on the Rinkeby test network.  Note that the latest geth is 1.7.1, not 1.6.1, but otherwise those instructions are correct.<commit_after>require "thor"
require "archangel"
require "date"

class ArchangelCLI < Thor
  class_option :driver, :desc => 'Backend driver to use [file|guardtime|ethereum]. Defaults to file'
  class_option :username, :desc => 'Guardtime username'
  class_option :password, :desc => '<PASSWORD>'
  class_option :dir, :desc => 'File storage root directory'

  desc "store ID PAYLOAD", "stores PAYLOAD for ID at the current time"
  def store(id, payload)
    storage().store(id, payload, DateTime.now)
  end # store

  desc "fetch ID", "retrieves the PAYLOAD previously stored with ID"
  def fetch(id)
    puts storage().fetch(id)
  end # fetch

  no_commands do
    def storage()
        Archangel.new(
          driver(options[:driver]),
          {
            :root => options[:dir],
            :username => options[:username],
            :password => options[:password]
          }
        )
    end

    def driver(name)
      case name
      when /^file$/i || /^filesystem$/i
        Archangel::Driver::Filesystem
      when /^guardtime$/i
        Archangel::Driver::GuardtimeV2
      when /^ethereum$/i
        Archangel::Driver::EtherStore
      when nil
{'fraction_non_alphanumeric': 0.11304347826086956, 'fraction_numerical': 0.009486166007905139, 'mean_word_length': 2.893846153846154, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3058067', 'n_tokens_mistral': 783, 'n_tokens_neox': 757, 'n_words': 233}