Class: Synotion::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/synotion/cli.rb

Instance Method Summary collapse

Instance Method Details

#sync(file_path) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/synotion/cli.rb', line 16

def sync(file_path)
  if options[:config] && File.exist?(options[:config])
    load_config_file(options[:config])
  end

  syncer_options = {}
  syncer_options[:notion_api_key] = options[:api_key] if options[:api_key]
  syncer_options[:database_id] = options[:database_id] if options[:database_id]
  syncer_options[:page_id] = options[:page_id] if options[:page_id]

  sync_options = {}
  sync_options[:mode] = options[:mode].to_sym if options[:mode]
  sync_options[:unique_property] = options[:unique_property] if options[:unique_property]
  sync_options[:unique_value] = options[:unique_value] if options[:unique_value]
  sync_options[:title] = options[:title] if options[:title]

  syncer = Syncer.new(syncer_options)
  result = syncer.sync(file_path, sync_options)

  puts "✓ Successfully #{result[:action]} page"
  puts "  Page ID: #{result[:page_id]}"
  puts "  Mode: #{result[:mode]}" if result[:mode]
rescue StandardError => e
  puts "✗ Error: #{e.message}"
  exit 1
end

#versionObject



44
45
46
# File 'lib/synotion/cli.rb', line 44

def version
  puts "Synotion version #{Synotion::VERSION}"
end