Class: Ronin::Repos::CLI::Commands::New Private

Inherits:
Ronin::Repos::CLI::Command show all
Includes:
Core::CLI::Generator
Defined in:
lib/ronin/repos/cli/commands/new.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Creates a new git repository.

Usage

ronin-repos new [options] PATH

Options

-C, --cache-dir DIR              Overrides the default cache directory
-h, --help                       Print help information

Arguments

PATH                             The path to the new repository

Instance Attribute Summary

Attributes inherited from Ronin::Repos::CLI::Command

#cache_dir

Instance Method Summary collapse

Methods inherited from Ronin::Repos::CLI::Command

#initialize

Constructor Details

This class inherits a constructor from Ronin::Repos::CLI::Command

Instance Method Details

#run(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Runs the ronin-repos new command.

Parameters:

  • path (String)

    The path to the new repo directory to create.



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ronin/repos/cli/commands/new.rb', line 65

def run(path)
  @name        = File.basename(path)
  @github_user = Core::Git.github_user || ENV['USER']

  mkdir path
  erb 'README.md.erb', File.join(path,'README.md')

  Dir.chdir(path) do
    sh 'git', 'init', '-q', '-b', 'main'
    sh 'git', 'add', 'README.md'
    sh 'git', 'commit', '-q', '-m', 'Initial commit.'
  end
end