Class: Star::Dlp::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/star/dlp/cli.rb

Instance Method Summary collapse

Instance Method Details

#configObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/star/dlp/cli.rb', line 75

def config
  config = Config.load
  
  # Override config with command line options
  config.github_token = options[:token] if options[:token]
  config.output_dir = options[:output_dir] if options[:output_dir]
  config.json_dir = options[:json_dir] if options[:json_dir]
  config.markdown_dir = options[:markdown_dir] if options[:markdown_dir]
  
  # Save config for future use
  config.save
  
  puts "Configuration saved successfully!"
  puts "GitHub Token: #{config.github_token || 'Not set'}"
  puts "Output Directory: #{config.output_dir}"
  puts "JSON Directory: #{config.json_dir}"
  puts "Markdown Directory: #{config.markdown_dir}"
end

#download(username) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/star/dlp/cli.rb', line 22

def download(username)
  config = Config.load
  
  # Override config with command line options
  config.github_token = options[:token] if options[:token]
  config.output_dir = options[:output_dir] if options[:output_dir]
  config.json_dir = options[:json_dir] if options[:json_dir]
  config.markdown_dir = options[:markdown_dir] if options[:markdown_dir]
  
  # Save config for future use
  config.save
  
  downloader = Downloader.new(
    config, 
    username, 
    thread_count: options[:threads],
    skip_readme: options[:skip_readme],
    retry_count: options[:retry_count],
    retry_delay: options[:retry_delay]
  )
  downloader.download
end

#download_readmeObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/star/dlp/cli.rb', line 50

def download_readme
  config = Config.load
  
  # Create a downloader instance
  downloader = Downloader.new(
    config,
    "readme_downloader", # Placeholder username
    thread_count: options[:threads],
    retry_count: options[:retry_count],
    retry_delay: options[:retry_delay]
  )
  
  # Call the download_readmes method in the Downloader class
  result = downloader.download_readmes(force: options[:force])
  
  puts "README download completed!"
  puts "Successfully downloaded: #{result[:success]}"
  puts "Failed or not found: #{result[:failed]}"
end

#versionObject



95
96
97
# File 'lib/star/dlp/cli.rb', line 95

def version
  puts "star-dlp version #{VERSION}"
end