Sha256: bace3c8f536ccbdefe5ddd72bcb1f089a1d6979f763097ce29d9a10b15f09c96

Contents?: true

Size: 1.78 KB

Versions: 2

Compression:

Stored size: 1.78 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
      class New < Command
        #
        # Creates a new standalone Ruby script.
        #
        # ## Usage
        #
        #     ronin new script PATH
        #
        # ## Arguments
        #
        #     PATH                             The script file to create
        #
        class Script < Command

          include Core::CLI::Generator

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

          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

2 entries across 2 versions & 1 rubygems

Version Path
ronin-2.1.0 lib/ronin/cli/commands/new/script.rb
ronin-2.1.0.rc1 lib/ronin/cli/commands/new/script.rb