<!DOCTYPE html>
<html lang="en" class="js csstransforms3d">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="generator" content="Hugo 0.74.3" />
    <meta name="description" content="">


    <link rel="icon" href="/rbcli/images/favicon.png" type="image/png">

    <title>The Project Layout :: RBCli Documentation</title>

    
    <link href="/rbcli/css/nucleus.css?1596148729" rel="stylesheet">
    <link href="/rbcli/css/fontawesome-all.min.css?1596148729" rel="stylesheet">
    <link href="/rbcli/css/hybrid.css?1596148729" rel="stylesheet">
    <link href="/rbcli/css/featherlight.min.css?1596148729" rel="stylesheet">
    <link href="/rbcli/css/perfect-scrollbar.min.css?1596148729" rel="stylesheet">
    <link href="/rbcli/css/auto-complete.css?1596148729" rel="stylesheet">
    <link href="/rbcli/css/atom-one-dark-reasonable.css?1596148729" rel="stylesheet">
    <link href="/rbcli/css/theme.css?1596148729" rel="stylesheet">
    <link href="/rbcli/css/hugo-theme.css?1596148729" rel="stylesheet">
    
    <link href="/rbcli/css/theme-blue.css?1596148729" rel="stylesheet">
    
    

    <script src="/rbcli/js/jquery-3.3.1.min.js?1596148729"></script>

    <style>
      :root #header + #content > #left > #rlblock_left{
          display:none !important;
      }
      
    </style>
    
  </head>
  <body class="" data-url="/rbcli/tutorial/20-project_layout/">
    <nav id="sidebar" class="">



  <div id="header-wrapper">
    <div id="header">
      <a id="logo" href="https://akhoury6.github.io/rbcli/" style="font-size: 40px">
  <span class="fas fa-terminal"></span>&nbsp;𝚁𝙱𝙲𝚕𝚒
</a>

    </div>
    
        <div class="searchbox">
    <label for="search-by"><i class="fas fa-search"></i></label>
    <input data-search-input id="search-by" type="search" placeholder="Search...">
    <span data-search-clear=""><i class="fas fa-times"></i></span>
</div>

<script type="text/javascript" src="/rbcli/js/lunr.min.js?1596148729"></script>
<script type="text/javascript" src="/rbcli/js/auto-complete.js?1596148729"></script>
<script type="text/javascript">
    
        var baseurl = "https:\/\/akhoury6.github.io\/rbcli\/";
    
</script>
<script type="text/javascript" src="/rbcli/js/search.js?1596148729"></script>

    
  </div>

    <div class="highlightable">
    <ul class="topics">

        
          
          




 
  
    
    <li data-nav-id="/rbcli/quick_reference/" title="Quick Reference" class="dd-item 
        
        
        
        ">
      <a href="/rbcli/quick_reference/">
          Quick Reference
          
      </a>
      
              
    </li>
  
 

          
          




 
  
    
    <li data-nav-id="/rbcli/tutorial/" title="Tutorial" class="dd-item 
        parent
        
        
        ">
      <a href="/rbcli/tutorial/">
          Tutorial
          
      </a>
      
      
        <ul>
          
          
          
          
        
          
            
            




 
  
    
      <li data-nav-id="/rbcli/tutorial/10-getting_started/" title="Getting Started" class="dd-item ">
        <a href="/rbcli/tutorial/10-getting_started/">
        <b>1. </b>Getting Started
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/tutorial/20-project_layout/" title="The Project Layout" class="dd-item active">
        <a href="/rbcli/tutorial/20-project_layout/">
        <b>2. </b>The Project Layout
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/tutorial/30-your_first_command/" title="Your First Command" class="dd-item ">
        <a href="/rbcli/tutorial/30-your_first_command/">
        <b>3. </b>Your First Command
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/tutorial/40-options_parameters_and_arguments/" title="Options, Parameters, and Arguments" class="dd-item ">
        <a href="/rbcli/tutorial/40-options_parameters_and_arguments/">
        <b>4. </b>Options, Parameters, and Arguments
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/tutorial/50-publishing/" title="Publishing Your Application" class="dd-item ">
        <a href="/rbcli/tutorial/50-publishing/">
        <b>5. </b>Publishing Your Application
        
        </a>
    </li>
     
  
 

            
          
        
        </ul>
              
    </li>
  
 

          
          




 
  
    
    <li data-nav-id="/rbcli/advanced/" title="Advanced" class="dd-item 
        
        
        
        ">
      <a href="/rbcli/advanced/">
          Advanced
          
      </a>
      
      
        <ul>
          
          
          
          
        
          
            
            




 
  
    
      <li data-nav-id="/rbcli/advanced/automatic_updates/" title="Automatic Updates" class="dd-item ">
        <a href="/rbcli/advanced/automatic_updates/">
        Automatic Updates
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/advanced/command_types/" title="Command Types" class="dd-item ">
        <a href="/rbcli/advanced/command_types/">
        Command Types
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/advanced/distributed_state_locking/" title="Distributed State and Locking" class="dd-item ">
        <a href="/rbcli/advanced/distributed_state_locking/">
        Distributed State and Locking
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/advanced/hooks/" title="Execution Hooks" class="dd-item ">
        <a href="/rbcli/advanced/hooks/">
        Execution Hooks
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/advanced/interactive_commands/" title="Interactive Commands" class="dd-item ">
        <a href="/rbcli/advanced/interactive_commands/">
        Interactive Commands
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/advanced/logging/" title="Logging" class="dd-item ">
        <a href="/rbcli/advanced/logging/">
        Logging
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/advanced/remote_execution/" title="Remote Execution" class="dd-item ">
        <a href="/rbcli/advanced/remote_execution/">
        Remote Execution
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/advanced/state_storage/" title="State Storage" class="dd-item ">
        <a href="/rbcli/advanced/state_storage/">
        State Storage
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/advanced/user_config_files/" title="User Configuration Files" class="dd-item ">
        <a href="/rbcli/advanced/user_config_files/">
        User Configuration Files
        
        </a>
    </li>
     
  
 

            
          
        
        </ul>
              
    </li>
  
 

          
          




 
  
    
    <li data-nav-id="/rbcli/development/" title="Development" class="dd-item 
        
        
        
        ">
      <a href="/rbcli/development/">
          Development
          
      </a>
      
      
        <ul>
          
          
          
          
        
          
            
            




 
  
    
      <li data-nav-id="/rbcli/development/contributing/" title="Contribution Guide" class="dd-item ">
        <a href="/rbcli/development/contributing/">
        Contribution Guide
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/development/license/" title="License Info" class="dd-item ">
        <a href="/rbcli/development/license/">
        License Info
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/development/code_of_conduct/" title="Code of Conduct" class="dd-item ">
        <a href="/rbcli/development/code_of_conduct/">
        Code of Conduct
        
        </a>
    </li>
     
  
 

            
          
            
            




 
  
    
      <li data-nav-id="/rbcli/development/changelog/" title="Changelog" class="dd-item ">
        <a href="/rbcli/development/changelog/">
        Changelog
        
        </a>
    </li>
     
  
 

            
          
        
        </ul>
              
    </li>
  
 

          
          




 
  
    
    <li data-nav-id="/rbcli/whoami/" title="My Letter To You" class="dd-item 
        
        
        
        ">
      <a href="/rbcli/whoami/">
          My Letter To You
          
      </a>
      
              
    </li>
  
 

          
         
    </ul>

    
    
      <section id="shortcuts">
        <h3>More</h3>
        <ul>
          
              <li> 
                  <a class="padding" href="https://github.com/akhoury6/rbcli"><i class='fab fa-github'></i> Github repo</a>
              </li>
          
              <li> 
                  <a class="padding" href="https://rubygems.org/gems/rbcli"><i class='far fa-gem'></i> Rubygems</a>
              </li>
          
        </ul>
      </section>
    

    
    <section id="footer">
      <p>Built with <a href="https://github.com/matcornic/hugo-theme-learn"><i class="fas fa-heart"></i></a> from <a href="https://getgrav.org">Grav</a> and <a href="https://gohugo.io/">Hugo</a></p>

    </section>
  </div>
</nav>




        <section id="body">
        <div id="overlay"></div>
        <div class="padding highlightable">
              
              <div>
                <div id="top-bar">
                
                
                <div id="breadcrumbs" itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb">
                    <span id="sidebar-toggle-span">
                        <a href="#" id="sidebar-toggle" data-sidebar-toggle="">
                          <i class="fas fa-bars"></i>
                        </a>
                    </span>
                  
                  <span id="toc-menu"><i class="fas fa-list-alt"></i></span>
                  
                  <span class="links">
                 
                 
                    
          
          
            
            
          
          
            
            
          
          
            <a href='/rbcli/'></a> > <a href='/rbcli/tutorial/'>Tutorial</a> > The Project Layout
          
        
          
        
          
        
                 
                  </span>
                </div>
                
                    <div class="progress">
    <div class="wrapper">
<nav id="TableOfContents">
  <ul>
    <li><a href="#project-initialization-types">Project Initialization Types</a>
      <ul>
        <li><a href="#project-mode">Project Mode</a></li>
        <li><a href="#mini--micro-modes">Mini &amp; Micro Modes</a></li>
      </ul>
    </li>
    <li><a href="#project-mode-structure">Project Mode Structure</a></li>
    <li><a href="#git-rubygems-and-rspec">Git, RubyGems, and rspec</a></li>
    <li><a href="#rbcli-folders">RBCli Folders</a></li>
    <li><a href="#next-steps">Next Steps</a></li>
  </ul>
</nav>
    </div>
</div>

                
              </div>
            </div>
            
        <div id="head-tags">
        
        </div>
        
        <div id="body-inner">
          
            <h1>
              
              The Project Layout
            </h1>
          

        


<p>Now we will learn about what an RBCli project looks like and how to start using it.</p>
<h2 id="project-initialization-types">Project Initialization Types</h2>
<p>RBCli can initialize a tool in three different modes:</p>
<ul>
<li>Project Mode (default)</li>
<li>Mini Mode</li>
<li>Micro Mode</li>
</ul>
<h3 id="project-mode">Project Mode</h3>
<p>If you&rsquo;ve been following along with the tutorial, you&rsquo;ve already seen Project Mode. An RBCli Project consists of several folders, each of which has a specific function. The RBCli framework handles loading and parsing the code automatically. To generate a standard, full-featured RBCli project, run:</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">rbcli init -n mytool
</code></pre></div><p>where <code>mytool</code> can be replaced with any other command name you&rsquo;d like. (We will continue using <code>mytool</code> in this tutorial though!)</p>
<p>Inside the newly created <code>mytool</code> folder you will see a bunch of files and folders related to your project. We will go over the structure later.</p>
<h3 id="mini--micro-modes">Mini &amp; Micro Modes</h3>
<p>If you need to write a CLI tool but project mode feels a bit overkill for you &ndash; if you think a single-file script is all that is needed &ndash; that&rsquo;s where the Mini and Micro modes come in. Instead of generating a full directory tree, you get only a single file that contains most of the functionality of RBCli. To use it, run:</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">rbcli init -n mytool -t mini
<span style="color:#75715e"># or</span>
rbcli init -n mytool -t micro
</code></pre></div><p>The only difference between the two is that <code>mini</code> will show you all available options and some documentation to help you, while <code>micro</code> is for advanced users who just want the samllest file possible.</p>
<p>As far as documentation goes, every piece of code present in those files is identical to Project mode so it should be pretty easy to navigate.</p>
<h2 id="project-mode-structure">Project Mode Structure</h2>
<p>An RBCli project has the following structure:</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-text" data-lang="text">&lt;name&gt;/
|--- application/
|   |--- commands/
|   |   |--- scripts/
|   |--- options.rb
|--- config/
|--- exe/
|   |--- &lt;name&gt;
|--- hooks/
|--- lib/
|   |--- &lt;name&gt;/
|   |--- &lt;name&gt;.rb
|--- spec/
|--- userconf/
|--- .gitignore
|--- .rbcli
|--- .rspec
|--- CODE_OF_CONDUCT.md
|--- Gemfile
|--- README.md
|--- Rakefile
|--- &lt;name&gt;.gemspec
</code></pre></div><h2 id="git-rubygems-and-rspec">Git, RubyGems, and rspec</h2>
<p>A few files aren&rsquo;t part of RBCli itself, but are provided for your convenience. If you&rsquo;re experienced in Ruby and Git you can skip over this.</p>
<ul>
<li><code>.gitignore</code>
<ul>
<li>Specifies which files to ignore in git. If you don&rsquo;t use git you can delete this file</li>
</ul>
</li>
<li><code>.rspec</code>
<ul>
<li>Configures Rspec for testing your code</li>
</ul>
</li>
<li><code>Gemfile</code>
<ul>
<li>Allows declaring dependencies for when your users install your application</li>
</ul>
</li>
<li><code>Gemspec</code>
<ul>
<li>Same as above, but also lets you fill in more information so that you can publish your application as a gem</li>
</ul>
</li>
<li><code>README.md</code>
<ul>
<li>A skeleton README file that will appear as a front page documentation to your code in most source control systems (i.e. Github, Bitbucket)</li>
</ul>
</li>
<li><code>CODE_OF_CONDUCT.md</code>
<ul>
<li>Taken directly from the <a href="http://contributor-covenant.org">contributor covenant</a> for your convenience</li>
</ul>
</li>
<li><code>Rakefile</code>
<ul>
<li>So you can run rspec tests as a rake task</li>
</ul>
</li>
</ul>
<p>There is a lot of controvesy online regarding using the <code>gemfile</code> vs the <code>gemspec</code>. If you are new to Ruby in general then I suggest declaring your dependencies in the gemspec and leaving the <code>gemfile</code> as-is. This keeps things simple and allows publishing and distributing your tool as a gem.</p>
<p>Additionally, note that a git repo is not created automatically. Using git is out of scope of this tutorial, but you can find tutorials <a href="https://www.tutorialspoint.com/git/">here</a>.</p>
<h2 id="rbcli-folders">RBCli Folders</h2>
<ul>
<li><code>application/</code>
<ul>
<li>This is where the core of your application will live. You will define CLI options, commands, scripts, and hooks within this folder.</li>
</ul>
</li>
<li><code>config/</code>
<ul>
<li>This folder contains the configuration for RBCli&rsquo;s features; such as storage, logging, and automatic updates.</li>
</ul>
</li>
<li><code>exe/</code>
<ul>
<li>This folder contains the executable for your tool. You should not edit it; doing so may lead to unexpected behavior.</li>
</ul>
</li>
<li><code>hooks/</code>
<ul>
<li>RBCli has several hooks that can be used to run code at different times, such as the &lsquo;default&rsquo; code that is run when no command is selected. This is where they are placed.</li>
</ul>
</li>
<li><code>lib/</code>
<ul>
<li>This folder is for you to write any additional code as you see fit, for importing into your commands, scripts, and hooks. It is automatically added to the $LOAD_PATH for you, so you can just use require statements like <code>require 'abc.rb'</code>  without worrying about where they are located on the filesystem.</li>
</ul>
</li>
<li><code>userconf/</code>
<ul>
<li>This folder is for you to place the layout and defaults of any userspace config file. Acceptable formats are yaml and json, though we recommend YAML since it is by far easier to read and supports comments.</li>
</ul>
</li>
<li><code>spec/</code>
<ul>
<li>This folder is for your rspec tests.</li>
</ul>
</li>
<li><code>.rbcli</code>
<ul>
<li>This file is for internal use by RBCli. It should not be modified or deleted.</li>
</ul>
</li>
</ul>
<h2 id="next-steps">Next Steps</h2>
<p>For the purposes of getting started right now, you don&rsquo;t actually need to edit any of the defaults already present.</p>
<p>We just finished going through what an RBCli project looks like. Now let&rsquo;s create our first application with it!</p>


<footer class="footline">
	
</footer>

        
        </div> 
        

      </div>

    <div id="navigation">
        
        
        
        
            
            
                
                    
                    
                
                

                    
                    
                        
                    
                    

                    
                        
            
            
                
                    
                        
                        
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                    
                
                

                    
                    
                    

                    
                        
            
            
                
                    
                        
                        
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                        
                        
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
            
        
                    
                        
            
            
                
                    
                
                

                    
                    
                    

                    
            
        
                    
            
        
        
        


	 
	 
		
			<a class="nav nav-prev" href="/rbcli/tutorial/10-getting_started/" title="Getting Started"> <i class="fa fa-chevron-left"></i></a>
		
		
			<a class="nav nav-next" href="/rbcli/tutorial/30-your_first_command/" title="Your First Command" style="margin-right: 0px;"><i class="fa fa-chevron-right"></i></a>
		
	
    </div>

    </section>
    
    <div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
      <div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
    </div>
    <script src="/rbcli/js/clipboard.min.js?1596148729"></script>
    <script src="/rbcli/js/perfect-scrollbar.min.js?1596148729"></script>
    <script src="/rbcli/js/perfect-scrollbar.jquery.min.js?1596148729"></script>
    <script src="/rbcli/js/jquery.sticky.js?1596148729"></script>
    <script src="/rbcli/js/featherlight.min.js?1596148729"></script>
    <script src="/rbcli/js/highlight.pack.js?1596148729"></script>
    <script>hljs.initHighlightingOnLoad();</script>
    <script src="/rbcli/js/modernizr.custom-3.6.0.js?1596148729"></script>
    <script src="/rbcli/js/learn.js?1596148729"></script>
    <script src="/rbcli/js/hugo-learn.js?1596148729"></script>

    <link href="/rbcli/mermaid/mermaid.css?1596148729" rel="stylesheet" />
    <script src="/rbcli/mermaid/mermaid.js?1596148729"></script>
    <script>
        mermaid.initialize({ startOnLoad: true });
    </script>
    

  </body>
</html>