diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..ed556da --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,22 @@ +AllCops: + NewCops: enable + +Layout/EmptyLinesAroundClassBody: + EnforcedStyle: 'empty_lines_except_namespace' +Layout/EmptyLinesAroundModuleBody: + EnforcedStyle: 'empty_lines_except_namespace' +Metrics/ClassLength: + Max: 150 +Metrics/MethodLength: + AllowedMethods: + - 'start' +Style/ClassVars: + Enabled: false +Style/GlobalVars: + Enabled: false +Style/MethodCallWithoutArgsParentheses: + Enabled: false +Style/MethodCallWithArgsParentheses: + Enabled: true +Style/RedundantReturn: + Enabled: false diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..7936775 --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,18 @@ +pipeline: + style: + image: ruby:3.0 + commands: + - 'gem install rake' + - 'bundle install' + - 'rake test:rubocop' + + gitea_release: + image: plugins/gitea-release + settings: + api_key: + from_secret: gitea_api_key + base_url: https://git.metaunix.net + title: "${CI_COMMIT_TAG}" + when: + event: tag + diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..c685972 --- /dev/null +++ b/Gemfile @@ -0,0 +1,8 @@ +source 'https://rubygems.org' + +gem 'dry-cli', '1.0.0' + +group :development, :test do + # rubocop and extensions for code style + gem 'rubocop' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..3fe6d68 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,40 @@ +GEM + remote: https://rubygems.org/ + specs: + ast (2.4.2) + dry-cli (1.0.0) + json (2.6.3) + language_server-protocol (3.17.0.3) + parallel (1.23.0) + parser (3.2.2.4) + ast (~> 2.4.1) + racc + racc (1.7.1) + rainbow (3.1.1) + regexp_parser (2.8.2) + rexml (3.2.6) + rubocop (1.57.2) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.2.2.4) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.30.0) + parser (>= 3.2.1.0) + ruby-progressbar (1.13.0) + unicode-display_width (2.5.0) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + dry-cli (= 1.0.0) + rubocop + +BUNDLED WITH + 2.3.5 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..bf73c9a --- /dev/null +++ b/Rakefile @@ -0,0 +1,15 @@ +require 'bundler/setup' + +task :run do + system("ruby src/pchwbm.rb") +end + +namespace :test do + task :all do + Rake::Task['test:rubocop'].invoke() + end + + task :rubocop do + system("rubocop src/") + end +end diff --git a/src/pchwbm.rb b/src/pchwbm.rb new file mode 100755 index 0000000..12d79d2 --- /dev/null +++ b/src/pchwbm.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby + +# frozen_string_literal: true + +require 'bundler/setup' +require 'dry/cli' + +module PCHWBM + module CLI + # Commands module for dry-cli + module Commands + + extend Dry::CLI::Registry + + # Version subcommand definition + class Version < Dry::CLI::Command + + desc 'Print program version.' + + def call(*) + puts('PCHWBM tool version 0.1.0.') + end + + end + + # Register commands with the CLI + register 'version', Version, aliases: ['v', '-v', '--version'] + + end + end +end + +# Run the CLI +Dry::CLI.new(PCHWBM::CLI::Commands).call()