Sha256: 5717b4bc2f825984bdad63b199ba8b9d1a70cfbf2ff7e2f4a237686a195f5046

Contents?: true

Size: 1.77 KB

Versions: 5

Compression:

Stored size: 1.77 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','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

5 entries across 5 versions & 1 rubygems

Version Path
ronin-2.0.5 lib/ronin/cli/commands/new/script.rb
ronin-2.0.4 lib/ronin/cli/commands/new/script.rb
ronin-2.0.3 lib/ronin/cli/commands/new/script.rb
ronin-2.0.2 lib/ronin/cli/commands/new/script.rb
ronin-2.0.1 lib/ronin/cli/commands/new/script.rb