lib/renuo/cli.rb in renuo-cli-3.1.7 vs lib/renuo/cli.rb in renuo-cli-4.2.0
- old
+ new
@@ -1,15 +1,19 @@
+# frozen_string_literal: true
+
require 'renuo/cli/version'
require 'rubygems'
require 'gems'
require 'colorize'
+require 'tmpdir'
+require 'net/http'
require 'renuo/cli/app/services/renuo_cli_config'
require 'renuo/cli/app/name_display'
require 'renuo/cli/app/local_storage'
require 'renuo/cli/app/list_large_git_files'
require 'renuo/cli/app/generate_password'
-require 'renuo/cli/app/upgrade_laptop.rb'
+require 'renuo/cli/app/upgrade_laptop'
require 'renuo/cli/app/create_aws_project'
require 'renuo/cli/app/create_heroku_app'
require 'renuo/cli/app/configure_sentry'
require 'renuo/cli/app/create_new_logins'
require 'renuo/cli/app/work'
@@ -19,11 +23,21 @@
require 'renuo/cli/app/setup_uptimerobot'
require 'renuo/cli/app/release_xing'
require 'renuo/cli/app/configure_semaphore'
require 'renuo/cli/app/toggl_redmine_comparator'
require 'renuo/cli/app/renuo_version'
+require 'renuo/cli/app/create_slidev_presentation'
+require 'renuo/cli/app/commit_leaderboard'
+require 'renuo/cli/app/commit_leaderboard_sync'
+require 'highline'
+def agree(question)
+ question += ' [y/n]' if question
+ super
+end
+
+# rubocop:disable Metrics/AbcSize, Metrics/ClassLength, Metrics/MethodLength
module Renuo
class CLI
def start
require 'commander/import'
program :version, Renuo::Cli::VERSION
@@ -38,11 +52,11 @@
abort 'Nice! I updated myself. 🤩 Now you can run the command again.'
end
abort('Good. Just do it yourself then...😒')
end
- command 'display-name'.to_sym do |c|
+ command :'display-name' do |c|
c.syntax = 'renuo display-name [options]'
c.summary = 'Sets the name of a customer on the Renuo dashboard'
c.description = 'Sets the name of a customer on the Renuo dashboard'
c.example 'Display "Peter Muster" on the dashboard', 'renuo display-name "Peter Muster"'
c.example 'Remove the current name from the dashboard', 'renuo display-name --delete'
@@ -69,11 +83,11 @@
command 'list-large-git-files' do |c|
c.syntax = 'renuo list-large-git-files'
c.summary = 'Lists the 5 largest files in a git repository. Warning: must be a bare checkout of the repo!'
c.description = "Lists the 5 largest files in a git repository.\nWarning: must be a bare checkout of the repo!"
c.example 'list the 5 largest git files of github.com/renuo/renuo-cli',
- 'git clone --bare git@github.com:renuo/renuo-cli.git && '\
+ 'git clone --bare git@github.com:renuo/renuo-cli.git && ' \
'cd renuo-cli.git && renuo list-large-git-files'
c.action do
ListLargeGitFiles.new.run
end
end
@@ -136,24 +150,24 @@
end
command 'work' do |c|
c.syntax = 'renuo work'
c.summary = 'A utility command to start working on a ticket.'
- c.description = 'When you start working on a feature, it will jump to the project folder, '\
- 'start a new feature with the ticket number,'\
- 'move the ticket in "In progress" state on Redmine and start Toggl with the '\
+ c.description = 'When you start working on a feature, it will jump to the project folder, ' \
+ 'start a new feature with the ticket number,' \
+ 'move the ticket in "In progress" state on Redmine and start Toggl with the ' \
'ticket number or add the ticket number to the running one if there was none.'
c.example 'renuo work start kinova 1234', 'start working on ticket 1234 on kinova project'
- c.action do|args|
+ c.action do |args|
Work.new.run(args)
end
end
command 'release' do |c|
c.syntax = 'renuo release'
c.summary = 'Release a projects state of develop (on github) to main in one command.'
- c.description = 'Creates a new release version of a project on main as either a Major, Minor, '\
+ c.description = 'Creates a new release version of a project on main as either a Major, Minor, ' \
'Patch or Custom release based on the current state of develop on Github'
c.example 'renuo release my-project minor', 'release a minor release of my-project'
c.example 'renuo release my-project custom 2.5.0', 'release my-project as release 2.5.0'
c.action do |args|
ReleaseProject.new.run(args)
@@ -172,12 +186,13 @@
command 'configure-sentry' do |c|
c.syntax = 'renuo configure-sentry [project-name] [SENTRY_DSN]'
c.summary = 'Generates the script necessary to setup sentry on Heroku.'
c.description = c.summary
- c.example 'renuo configure-sentry myproject https://randomkey@sentry.io/11223344', 'generates the command to configure sentry for myproject on Heroku'
- c.action do|args|
+ c.example 'renuo configure-sentry myproject https://randomkey@sentry.io/11223344',
+ 'generates the command to configure sentry for myproject on Heroku'
+ c.action do |args|
ConfigureSentry.new.run(args)
end
end
command 'fetch-emails' do |c|
@@ -203,46 +218,88 @@
end
command 'setup-uptimerobot' do |c|
c.syntax = 'renuo setup-uptimerobot'
c.summary = 'Sets up uptimerobot for the given project'
- c.description = "The uptimerobot configuration is mandatory for most projects. "\
- "This command sets everything up and pauses the monitoring directly. Once the app is ready,"\
- " the monitoring should get started."
+ c.description = 'The uptimerobot configuration is mandatory for most projects. ' \
+ 'This command sets everything up and pauses the monitoring directly. Once the app is ready, ' \
+ 'the monitoring should get started.'
c.example 'renuo setup-uptimerobot https://redmine.ch', 'Configures redmine monitoring on uptimerobot'
c.action do |args|
SetupUptimerobot.new(args).run
end
end
command 'release-xing' do |c|
c.syntax = 'renuo release-xing'
c.summary = 'Release Xing to preview.'
- c.description = "Xing needs to be released manually. "\
- "You need a VPN connection open before runnign this command."
- c.action do |args|
+ c.description = 'Xing needs to be released manually. ' \
+ 'You need a VPN connection open before runnign this command.'
+ c.action do |_args|
ReleaseXing.new.run
end
end
command 'configure-semaphore' do |c|
c.syntax = 'renuo configure-semaphore'
c.summary = 'Adds standard semaphore configuration files to a project and creates the notifications'
- c.description = 'Run this command with a project, to add the semaphore configuration files '\
+ c.description = 'Run this command with a project, to add the semaphore configuration files ' \
'and create notifications.'
- c.action do |args|
+ c.action do |_args|
ConfigureSemaphore.new.call
end
end
command 'toggl-redmine' do |c|
c.syntax = 'renuo toggl-redmine'
c.summary = 'Compares your time entries between Toggl and Redmine'
- c.description = 'This command extracts your time entries in Toggl and in Redmine and checks if they are'\
- ' consistant. It can help you in your time booking to find if you booked something wrong'
- c.action do |args|
+ c.description = 'This command extracts your time entries in Toggl and in Redmine and checks if they are ' \
+ 'consistant. It can help you in your time booking to find if you booked something wrong'
+ c.action do |_args|
TogglRedmineComparator.call
end
end
+
+ command 'create-slidev-presentation' do |c|
+ c.syntax = 'renuo create-slidev-presentation [presentation-name]'
+ c.summary = 'Creates a new Slidev presentation with the Renuo theme'
+ c.description = 'Creates a new Slidev presentation with the Renuo theme'
+ c.action do |args|
+ CreateSlidevPresentation.new.run(args)
+ end
+ end
+
+ command 'commit-leaderboard-stage' do |c|
+ c.syntax = 'renuo commit-leaderboard-stage [username] [avatar-url] [queue-path]'
+ c.summary = 'Adds local commits to a local queue for the commit leaderboard'
+ c.description = <<~DESCRIPTION
+ Add post-commit hook to `git config core.hookspath` with the following contents:
+
+ #!/usr/bin/env sh
+ renuo commit-leaderboard-stage CuddlyBunion341 "https://avatars.githubusercontent.com/u/53896675?v=4" ~/.renuo-commit-leaderboard.json
+
+ # You can get the GitHub avatar url using `gh api user | jq .avatar_url`
+ DESCRIPTION
+
+ c.action do |args|
+ CommitLeaderboard.new.run(args)
+ end
+ end
+
+ command 'commit-leaderboard-sync' do |c|
+ c.syntax = 'renuo commit-leaderboard-sync [api-secret] [queue-path] [api-url]'
+ c.summary = 'Sends commits from the queue to the commit leaderboard'
+ c.description = <<~DESCRIPTION
+ Sends commits from the queue to the commit leaderboard
+ Add pre-push hook to `git config core.hookspath` with the following contents:
+
+ #/usr/bin/env sh
+ renuo commit-leaderboard-sync {SECRET} ~/.renuo-commit-leaderboard.json https://dashboard.renuo.ch/api/v1/commit_leaderboard
+ DESCRIPTION
+ c.action do |args|
+ CommitLeaderboardSync.new.run(args)
+ end
+ end
end
end
end
+# rubocop:enable Metrics/AbcSize, Metrics/ClassLength, Metrics/MethodLength