Sha256: 9450ba7a8cc8abb8754fe40c6c2abf1de97d0be5deae70981035e9e59b62775e

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

module Memo
  class Cli
    module Command
      class Setup
        def initialize(
          _,
          os: Memo::OS.new
        )
          @os = os
          @config = Memo::Config.new
        end

        def call
          toml = <<~TOML
            [config]
            # ext = "md"
            # root = "~/.memo"
            # editor = "vim"
            # preview = "bat"
            # fuzzy_finder = "fzf --preview 'bat --color=always {}'"
            # default_filename = "memo"
            # default_namespace = "mymemo"

            [namespace_alias]
            # p1 = "project1"

            [command_alias]
            # ep1 = "edit memo -n project1"
          TOML

          if ::File.exist? @config.path
            puts "WARNING: config file already exists"
            puts
            print "reset config? (y/n) "
            ans = STDIN.gets.chomp
            if ans != "y"
              puts "aborted"
              return
            end
          end

          @os.write @config.path, toml

          puts
          puts <<~TEXT
            Create config file to #{@config.path}
            You can edit by `$ memo config`
          TEXT
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ememo-0.2.1 lib/memo/cli/command/setup.rb
ememo-0.1.8 lib/memo/cli/command/setup.rb
ememo-0.1.7 lib/memo/cli/command/setup.rb
ememo-0.1.6 lib/memo/cli/command/setup.rb
ememo-0.1.5 lib/memo/cli/command/setup.rb
ememo-0.1.4 lib/memo/cli/command/setup.rb
ememo-0.1.3 lib/memo/cli/command/setup.rb
ememo-0.1.2 lib/memo/cli/command/setup.rb