Sha256: 54344a110c4324c429b58de88d49b935580945271b40ab1ebd22baa00e70941c

Contents?: true

Size: 1.75 KB

Versions: 6

Compression:

Stored size: 1.75 KB

Contents

# frozen_string_literal: true
#
# Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# Ronin is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ronin is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ronin.  If not, see <https://www.gnu.org/licenses/>.
#

require 'ronin/cli/command'
require 'ronin/core/cli/generator'
require 'ronin/root'

module Ronin
  class CLI
    module Commands
      #
      # Creates a new standalone Ruby script.
      #
      # ## Usage
      #
      #     ronin new script PATH
      #
      # ## Arguments
      #
      #     PATH                             The script file to create
      #
      class New < Command
        class Script < Command

          include Core::CLI::Generator

          template_dir File.join(ROOT,'data','new')

          usage' PATH'

          argument :path, required: true,
                          desc:     'The script file to create'

          description 'Creates a new standalone Ruby script'

          man_page 'ronin-new-script.1'

          #
          # Runs the `ronin new script` command.
          #
          # @param [String] path
          #   The path to the new script file to create.
          #
          def run(path)
            erb 'script.rb.erb', path
            chmod '+x', path
          end

        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ronin-2.0.0 lib/ronin/cli/commands/new/script.rb
ronin-2.0.0.beta5 lib/ronin/cli/commands/new/script.rb
ronin-2.0.0.beta4 lib/ronin/cli/commands/new/script.rb
ronin-2.0.0.beta3 lib/ronin/cli/commands/new/script.rb
ronin-2.0.0.beta2 lib/ronin/cli/commands/new/script.rb
ronin-2.0.0.beta1 lib/ronin/cli/commands/new/script.rb