lib/backup_repos/cli/setup.rb in backup_repos-0.3.0 vs lib/backup_repos/cli/setup.rb in backup_repos-0.4.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module BackupRepos
module CLI
class Setup
attr_reader :options, :config
@@ -31,10 +33,14 @@
end
if cli.agree '* Are you want to backup BitBucket repositories?'
configure_bitbucket
end
+
+ if cli.agree '* Are you want to backup GitLab repositories?'
+ configure_gitlab
+ end
end
def configure_backup_directory
cli.say '* To what directory you want to backup?'
@backup_directory = cli.ask ' Backup directory: ' do |q|
@@ -74,9 +80,29 @@
@config[:github][:access_token] = access_token if access_token.present?
if exclude_repositories.present?
@config[:github][:exclude] = exclude_repositories
end
+ end
+
+ def configure_gitlab
+ @config[:gitlab] ||= []
+
+ cli.say ' GitLab Endpoint. Use this for self-hosted GitLab or press Enter to skip.'
+ endpoint = cli.ask ' Endpoint: '
+ cli.say ' What is your GitLab private token?'
+ private_token = cli.ask ' Private Token: '
+ exclude_repositories = cli.ask(
+ ' Exclude repositories or organizations (separate by space): ', Array
+ )
+
+ config = {}
+ config[:endpoint] = endpoint if endpoint.present?
+ config[:private_token] = private_token if private_token.present?
+
+ config[:exclude] = exclude_repositories if exclude_repositories.present?
+
+ @config[:gitlab] << config
end
def configure_bitbucket
cli.say ' What is your BitBucket credentials?'
username = ask(' Username: ')