Class: S3Browser

Inherits:
Object
  • Object
show all
Includes:
Tui::Helpers
Defined in:
lib/betters3tui.rb

Constant Summary collapse

NODE_HEIGHT =
4

Instance Method Summary collapse

Methods included from Tui::Helpers

#accent, #bold, #dim, #emoji, #fill, #highlight

Constructor Details

#initializeS3Browser

Returns a new instance of S3Browser.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/betters3tui.rb', line 21

def initialize
  @profiles = load_profiles
  @current_profile = nil
  @s3_client = nil
  @buckets = []
  @current_bucket = nil
  @objects = []
  @current_prefix = ""
  @selected_index = 0
  @scroll_offset = 0
  @mode = :profile_select  # :profile_select, :bucket_select, :object_list, :add_profile, :edit_profile, :sort_menu

  # Profile creation/edit state
  @new_profile = {}
  @profile_fields = [
    { key: 'name', label: 'Profile Name', required: true },
    { key: 'endpoint', label: 'Endpoint URL', required: false },
    { key: 'access_key', label: 'Access Key', required: true },
    { key: 'secret_key', label: 'Secret Key', required: true, secret: true },
    { key: 'region', label: 'Region', required: false },
    { key: 'is_aws', label: 'Is AWS? (y/n)', required: false, boolean: true }
  ]
  @current_field_index = 0
  @editing_profile_index = nil

  # Delete confirmation state
  @delete_confirm_mode = false
  @delete_profile_name = nil

  # Search state
  @search_mode = false
  @search_query = String.new
  @search_results = []
  @search_cursor = 0

  # Sort state
  @sort_by = :name
  @sort_direction = :asc

  # Sort menu state
  @sort_menu_options = [
    { key: 'n', label: 'Name', value: :name },
    { key: 's', label: 'Size', value: :size },
    { key: 'd', label: 'Date', value: :date }
  ]
  @sort_menu_index = 0

  # Loading state
  @loading = false
  @loading_message = ""
end

Instance Method Details

#runObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/betters3tui.rb', line 73

def run
  ensure_profiles_file_exists
  setup_terminal

  loop do
    render
    handle_input
  end
rescue Interrupt
  cleanup_terminal
  puts "\nGoodbye!"
ensure
  cleanup_terminal
end