Repository: mrsked/mrsk
File: lib/kamal/cli/main.rb (Ruby)

Code before:
        end
        puts "Created binstub file in bin/kamal"
      end
    end
  end

  desc "envify", "Create .env by evaluating .env.erb (or .env.staging.erb -> .env.staging when using -d staging)"
  option :skip_push, aliases: "-P", type: :boolean, default: false, desc: "Skip .env file push"
  def envify
    if destination = options[:destination]
      env_template_path = ".env.#{destination}.erb"
      env_path          = ".env.#{destination}"
    else
      env_template_path = ".env.erb"
      env_path          = ".env"
    end

    if File.exist?(env_template_path)
      File.write(env_path, ERB.new(File.read(env_template_path), trim_mode: "-").result, perm: 0600)

      unless options[:skip_push]
        reload_envs
        invoke "kamal:cli:env:push", options
      end
    else
      puts "Skipping envify (no #{env_template_path} exist)"
    end
  end

  desc "remove", "Remove Traefik, app, accessories, and registry session from servers"
  option :confirmed, aliases: "-y", type: :boolean, default: false, desc: "Proceed without confirmation question"
  def remove
    mutating do
      confirming "This will remove all containers and images. Are you sure?" do
        invoke "kamal:cli:traefik:remove", [], options.without(:confirmed)
        invoke "kamal:cli:app:remove", [], options.without(:confirmed)
        invoke "kamal:cli:accessory:remove", [ "all" ], options
        invoke "kamal:cli:registry:logout", [], options.without(:confirmed)
      end
    end
  end

  desc "version", "Show Kamal version"
  def version
    puts Kamal::VERSION
  end

  desc "accessory", "Manage accessories (db/redis/search)"
  subcommand "accessory", Kamal::Cli::Accessory

  desc "app", "Manage application"

Review comment (suggestion):
I'd keep using `say` as in other places.

```suggestion
      say "Skipping envify (no #{env_template_path} exist)", :magenta
```


Code after:
        end
        puts "Created binstub file in bin/kamal"
      end
    end
  end

  desc "envify", "Create .env by evaluating .env.erb (or .env.staging.erb -> .env.staging when using -d staging)"
  option :skip_push, aliases: "-P", type: :boolean, default: false, desc: "Skip .env file push"
  def envify
    if destination = options[:destination]
      env_template_path = ".env.#{destination}.erb"
      env_path          = ".env.#{destination}"
    else
      env_template_path = ".env.erb"
      env_path          = ".env"
    end

    if Pathname.new(File.expand_path(env_template_path)).exist?
      File.write(env_path, ERB.new(File.read(env_template_path), trim_mode: "-").result, perm: 0600)

      unless options[:skip_push]
        reload_envs
        invoke "kamal:cli:env:push", options
      end
    else
      puts "Skipping envify (no #{env_template_path} exist)"
    end
  end

  desc "remove", "Remove Traefik, app, accessories, and registry session from servers"
  option :confirmed, aliases: "-y", type: :boolean, default: false, desc: "Proceed without confirmation question"
  def remove
    mutating do
      confirming "This will remove all containers and images. Are you sure?" do
        invoke "kamal:cli:traefik:remove", [], options.without(:confirmed)
        invoke "kamal:cli:app:remove", [], options.without(:confirmed)
        invoke "kamal:cli:accessory:remove", [ "all" ], options
        invoke "kamal:cli:registry:logout", [], options.without(:confirmed)
      end
    end
  end

  desc "version", "Show Kamal version"
  def version
    puts Kamal::VERSION
  end

  desc "accessory", "Manage accessories (db/redis/search)"
  subcommand "accessory", Kamal::Cli::Accessory

  desc "app", "Manage application"