 8adc188992
			
		
	
	
		8adc188992
		
			
		
	
	
	
	
		
			
			Import these from the homebrew/aliases tap and deprecate that tap. This required a little messing around with class/module/constant names to get `brew tests` and `brew typecheck` to play nicely. I added also added Sorbet type signatures and integration tests.
		
			
				
	
	
		
			48 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Ruby
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Ruby
		
	
	
		
			Executable File
		
	
	
	
	
| # typed: strict
 | |
| # frozen_string_literal: true
 | |
| 
 | |
| require "abstract_command"
 | |
| require "aliases/aliases"
 | |
| 
 | |
| module Homebrew
 | |
|   module Cmd
 | |
|     class Alias < AbstractCommand
 | |
|       cmd_args do
 | |
|         usage_banner "`alias` [<alias> ... | <alias>=<command>]"
 | |
|         description <<~EOS
 | |
|           Show existing aliases. If no aliases are given, print the whole list.
 | |
|         EOS
 | |
|         switch "--edit",
 | |
|                description: "Edit aliases in a text editor. Either one or all aliases may be opened at once. " \
 | |
|                             "If the given alias doesn't exist it'll be pre-populated with a template."
 | |
|         named_args max: 1
 | |
|       end
 | |
| 
 | |
|       sig { override.void }
 | |
|       def run
 | |
|         name = args.named.first
 | |
|         name, command = name.split("=", 2) if name.present?
 | |
| 
 | |
|         Aliases.init
 | |
| 
 | |
|         if name.nil?
 | |
|           if args.edit?
 | |
|             Aliases.edit_all
 | |
|           else
 | |
|             Aliases.show
 | |
|           end
 | |
|         elsif command.nil?
 | |
|           if args.edit?
 | |
|             Aliases.edit name
 | |
|           else
 | |
|             Aliases.show name
 | |
|           end
 | |
|         else
 | |
|           Aliases.add name, command
 | |
|           Aliases.edit name if args.edit?
 | |
|         end
 | |
|       end
 | |
|     end
 | |
|   end
 | |
| end
 |