lib/datapimp/cli/sync.rb in datapimp-1.0.29 vs lib/datapimp/cli/sync.rb in datapimp-1.1.0
- old
+ new
@@ -19,18 +19,44 @@
c.description = "Synchronize the contents of a local data store with its remote source"
c.syntax = "datapimp sync data [OPTIONS]"
c.option '--type TYPE', String, "What type of source data is this? #{ Datapimp::Sync.data_source_types.join(", ") }"
c.option '--output FILE', String, "Write the output to a file"
+ c.option '--format FORMAT', String, "Which format to serialize the output in? valid options are JSON"
c.option '--columns NAMES', Array, "Extract only these columns"
+ c.option '--relations NAMES', Array, "Also fetch these relationships on the object if applicable"
c.example "Syncing an excel file from dropbox ", "datapimp sync data --type dropbox --columns name,description --dropbox-app-key ABC --dropbox-app-secret DEF --dropbox-client-token HIJ --dropbox-client-secret JKL spreadsheets/test.xslx"
c.example "Syncing a google spreadsheet", "datapimp sync data --type google-spreadsheet WHATEVER_THE_KEY_IS"
Datapimp::Cli.accepts_keys_for(c, :google, :github, :dropbox)
c.action do |args, options|
if options.type == "google-spreadsheet" || options.type == "google"
Datapimp::DataSync.sync_google_spreadsheet(options, args)
+
+ # TODO
+ # Could totally make this cleaner if we need to support more services
+ elsif options.type == "github-issues"
+ repository = args.shift
+
+ service = Datapimp::DataSync::Github.new(repository, options)
+ service.sync_issues
+ elsif options.type == "github-milestones"
+ repository = args.shift
+
+ service = Datapimp::DataSync::Github.new(repository, options)
+ service.sync_milestones
+ elsif options.type == "github-releases"
+ repository = args.shift
+
+ service = Datapimp::DataSync::Github.new(repository, options)
+ service.sync_releases
+ elsif options.type == "github-issue-comments"
+ repository = args.shift
+ issue = args.shift
+
+ service = Datapimp::DataSync::Github.new(repository, options)
+ service.sync_issue_comments(issue)
end
end
end