@@ -464,24 +464,22 @@ def parse_project_selection(selection: str, max_projects: int) -> list[int]:
464464def select_jira_projects (
465465 projects_file : str ,
466466 jira_config : JiraConfig | None ,
467- save_selection : bool = False ,
468467) -> list [str ]:
469- """Select Jira projects interactively or from file .
468+ """Select Jira projects from file or use all available .
470469
471470 Args:
472471 projects_file: Path to jira_projects.txt file.
473- jira_config: Jira configuration (required for interactive selection).
474- save_selection: Whether to save selection to file.
472+ jira_config: Jira configuration (required to fetch available projects).
475473
476474 Returns:
477- List of selected project keys.
475+ List of project keys to analyze .
478476 """
479477 # Try loading from file first
480478 file_projects = load_jira_projects (projects_file )
481479 if file_projects :
482480 return file_projects
483481
484- # No file or empty - need interactive selection
482+ # No file or empty - use all available projects
485483 if not jira_config :
486484 return []
487485
@@ -495,31 +493,11 @@ def select_jira_projects(
495493 print ("No projects found in Jira instance." )
496494 return []
497495
498- # Display projects
499- print ("\n Available Jira projects:" )
500- print (format_project_list (available_projects ))
501- print ("\n Enter project numbers (e.g., '1,3,5' or '1-3' or 'all'):" )
496+ # Use all available projects
497+ all_keys = [p .key for p in available_projects ]
498+ print (f"\n No { projects_file } found. Using all { len (all_keys )} available Jira projects." )
502499
503- try :
504- selection = input ("> " ).strip ()
505- indices = parse_project_selection (selection , len (available_projects ))
506-
507- if not indices :
508- print ("No valid projects selected." )
509- return []
510-
511- selected = [available_projects [i ].key for i in indices ]
512-
513- # Optionally save to file
514- if save_selection and prompt_yes_no ("Save selection to file for future use?" , default = True ):
515- Path (projects_file ).write_text ("\n " .join (selected ) + "\n " )
516- print (f"Saved to { projects_file } " )
517-
518- return selected
519-
520- except (EOFError , KeyboardInterrupt ):
521- print ("\n Selection cancelled." )
522- return []
500+ return all_keys
523501
524502
525503def run_extraction (
@@ -576,7 +554,7 @@ def run_extraction(
576554
577555 # Get Jira projects
578556 projects_file = jira_projects_file or jira_config .jira_projects_file
579- project_keys = select_jira_projects (projects_file , jira_config , save_selection = True )
557+ project_keys = select_jira_projects (projects_file , jira_config )
580558
581559 if not project_keys :
582560 print ("No Jira projects selected. Skipping Jira extraction." )
@@ -634,6 +612,18 @@ def main() -> int:
634612
635613 config .validate ()
636614
615+ # Determine data sources
616+ if args .sources == "auto" :
617+ sources = auto_detect_sources ()
618+ if not sources :
619+ output .error ("No data sources available. Set GITHUB_TOKEN or Jira credentials." )
620+ return 1
621+ output .log (f"Auto-detected sources: { ', ' .join (s .value for s in sources )} " , "info" )
622+ else :
623+ sources = parse_sources_list (args .sources )
624+ validate_sources (sources )
625+ output .log (f"Using sources: { ', ' .join (s .value for s in sources )} " , "info" )
626+
637627 # Interactive prompts for options not provided via CLI
638628 print ()
639629
@@ -664,13 +654,29 @@ def main() -> int:
664654 output .log (f"Verbose mode: { 'Yes' if config .verbose else 'No' } " , "info" )
665655 output .log (f"Full PR details: { 'Yes' if fetch_pr_details else 'No' } " , "info" )
666656
667- # Load repositories
668- output .log (f"Loading repositories from { config .repos_file } ..." )
669- repositories = load_repositories (config .repos_file )
670- output .log (f"Found { len (repositories )} repositories to analyze" , "success" )
671-
672- for repo in repositories :
673- output .log (f" • { repo .full_name } " , "info" )
657+ # Load GitHub repositories if GitHub source is enabled
658+ repositories = []
659+ if DataSource .GITHUB in sources :
660+ output .log (f"Loading repositories from { config .repos_file } ..." )
661+ repositories = load_repositories (config .repos_file )
662+ output .log (f"Found { len (repositories )} repositories to analyze" , "success" )
663+
664+ for repo in repositories :
665+ output .log (f" • { repo .full_name } " , "info" )
666+
667+ # Load Jira projects if Jira source is enabled
668+ jira_config = None
669+ project_keys : list [str ] = []
670+ if DataSource .JIRA in sources :
671+ jira_config = JiraConfig .from_env ()
672+ if jira_config :
673+ projects_file = args .jira_projects or jira_config .jira_projects_file
674+ project_keys = select_jira_projects (projects_file , jira_config )
675+ output .log (f"Found { len (project_keys )} Jira projects to analyze" , "success" )
676+ for key in project_keys [:5 ]:
677+ output .log (f" • { key } " , "info" )
678+ if len (project_keys ) > 5 :
679+ output .log (f" ... and { len (project_keys ) - 5 } more" , "info" )
674680
675681 # Confirm before starting
676682 print ()
@@ -681,11 +687,41 @@ def main() -> int:
681687 # Run analysis
682688 output .section ("🚀 ANALYSIS" )
683689
684- analyzer = GitHubAnalyzer (config , fetch_pr_details = fetch_pr_details )
685- try :
686- analyzer .run (repositories )
687- finally :
688- analyzer .close ()
690+ # Run GitHub analysis
691+ if DataSource .GITHUB in sources and repositories :
692+ output .log ("Starting GitHub analysis..." , "info" )
693+ analyzer = GitHubAnalyzer (config , fetch_pr_details = fetch_pr_details )
694+ try :
695+ analyzer .run (repositories )
696+ finally :
697+ analyzer .close ()
698+
699+ # Run Jira extraction
700+ if DataSource .JIRA in sources and jira_config and project_keys :
701+ output .log ("Starting Jira extraction..." , "info" )
702+ from src .github_analyzer .api .jira_client import JiraClient
703+
704+ client = JiraClient (jira_config )
705+ since = datetime .now (timezone .utc ) - timedelta (days = config .days )
706+
707+ # Collect issues and comments
708+ output .log (f"Fetching issues from { len (project_keys )} projects..." , "info" )
709+ all_issues = list (client .search_issues (project_keys , since ))
710+ output .log (f"Found { len (all_issues )} issues" , "success" )
711+
712+ output .log ("Fetching comments..." , "info" )
713+ all_comments = []
714+ for issue in all_issues :
715+ comments = client .get_comments (issue .key )
716+ all_comments .extend (comments )
717+ output .log (f"Found { len (all_comments )} comments" , "success" )
718+
719+ # Export Jira data to CSV
720+ jira_exporter = JiraExporter (config .output_dir )
721+ issues_file = jira_exporter .export_issues (all_issues )
722+ comments_file = jira_exporter .export_comments (all_comments )
723+ output .log (f"Exported Jira issues to { issues_file } " , "success" )
724+ output .log (f"Exported Jira comments to { comments_file } " , "success" )
689725
690726 return 0
691727
0 commit comments