Class: GitFit::ExportCLI
- Inherits:
-
Thor
- Object
- Thor
- GitFit::ExportCLI
- Defined in:
- lib/git_fit/cli/export.rb
Instance Method Summary collapse
Instance Method Details
#ai ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/git_fit/cli/export.rb', line 87 def ai config = git_fit_config unless config.ai_config['enabled'] say_status :warn, 'AI: ai.enabled is false, skipping (Fix: set ai.enabled: true or GIT_FIT_AI_ENABLED=true)', :yellow return end client = GitFit::LLM::Client.from_config(config) return if client.nil? # unreachable: disabled handled above conn = GitFit::DB::Connection.new(config.db_path) conn.migrate! path = [:output] || config.export_config.dig('ai', 'path') || 'site/insights.json' doc = Export::AI.new(db: conn.db, config: config, client: client, output: path, period: [:period], language: [:lang]).call if doc sections = %w[summary_markdown insights coaching].count { |k| doc[k] } say_status :done, "Exported AI insights to #{path} (#{sections}/3 sections)", :green else say_status :warn, 'AI: nothing to do (empty db or insights unchanged)', :yellow end rescue GitFit::LLM::Error => e # AI failures are non-fatal by contract — CI deploys must not break. say_status :warn, e., :yellow end |
#csv ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/git_fit/cli/export.rb', line 35 def csv config = git_fit_config conn = GitFit::DB::Connection.new(config.db_path) conn.migrate! db = conn.db path = [:output] || config.export_config.dig('csv', 'path') || 'site/workouts.csv' filter = [:activity]&.map(&:strip)&.map(&:downcase) count = Export::CSV.new(db: db, output: path, activity_filter: filter).call say_status :done, "Exported #{count} activities to #{path}", :green rescue StandardError => e say_status :error, "CSV export failed: #{e.}", :red end |
#gpx ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/git_fit/cli/export.rb', line 52 def gpx config = git_fit_config conn = GitFit::DB::Connection.new(config.db_path) conn.migrate! db = conn.db path = [:output] || config.export_config.dig('gpx', 'path') || 'site/gpx_out' filter = [:activity]&.map(&:strip)&.map(&:downcase) count = Export::GPX.new(db: db, output: path, activity_filter: filter).call say_status :done, "Exported #{count} GPX files to #{path}/", :green rescue StandardError => e say_status :error, "GPX export failed: #{e.}", :red end |
#json ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/git_fit/cli/export.rb', line 17 def json config = git_fit_config conn = GitFit::DB::Connection.new(config.db_path) conn.migrate! db = conn.db path = [:output] || config.export_config.dig('json', 'path') || 'site/activities.json' filter = [:activity]&.map(&:strip)&.map(&:downcase) count = Export::JSON.new(db: db, output: path, activity_filter: filter, tracks_output: [:tracks_output]).call say_status :done, "Exported #{count} activities to #{path}", :green rescue StandardError => e say_status :error, "JSON export failed: #{e.}", :red end |
#stats ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/git_fit/cli/export.rb', line 69 def stats config = git_fit_config conn = GitFit::DB::Connection.new(config.db_path) conn.migrate! db = conn.db path = [:output] || config.export_config.dig('stats', 'path') || 'site/stats.json' filter = [:activity]&.map(&:strip)&.map(&:downcase) count = Export::Stats.new(db: db, output: path, activity_filter: filter).call say_status :done, "Exported stats for #{count} activities to #{path}", :green rescue StandardError => e say_status :error, "Stats export failed: #{e.}", :red end |