MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / launch_gitql_repl

Function launch_gitql_repl

src/main.rs:90–176  ·  view source on GitHub ↗
(arguments: &Arguments)

Source from the content-addressed store, hash-verified

88use gitql::gitql_line_editor::create_new_line_editor;
89
90fn launch_gitql_repl(arguments: &Arguments) {
91 let mut reporter = diagnostic_reporter::DiagnosticReporter::default();
92 let git_repos_result = validate_git_repositories(&arguments.repos);
93 if git_repos_result.is_err() {
94 reporter.report_diagnostic(
95 "",
96 Diagnostic::error(git_repos_result.err().unwrap().as_str()),
97 );
98 std::process::exit(1);
99 }
100
101 let git_repositories = git_repos_result.ok().unwrap();
102 let mut global_env = create_gitql_environment();
103
104 // Launch the right line editor if the flag is enabled
105 // Later this line editor will be the default editor
106 if arguments.enable_line_editor {
107 let mut line_editor = create_new_line_editor();
108 loop {
109 if let Ok(LineEditorResult::Success(input)) = line_editor.read_line() {
110 println!();
111
112 if input.is_empty() || input == "\n" {
113 continue;
114 }
115
116 if input == "exit" {
117 break;
118 }
119
120 execute_gitql_query(
121 &input,
122 arguments,
123 &git_repositories,
124 &mut global_env,
125 &mut reporter,
126 );
127
128 global_env.clear_session();
129 }
130 }
131 return;
132 }
133
134 let mut input = String::new();
135 loop {
136 let stdin = io::stdin();
137
138 // Render Prompt only if input is received from terminal
139 if stdin.is_terminal() {
140 print!("gitql > ");
141 }
142
143 std::io::Write::flush(&mut std::io::stdout()).expect("flush failed!");
144 match stdin.read_line(&mut input) {
145 Ok(buffer_length) => {
146 if buffer_length == 0 {
147 break;

Callers 1

mainFunction · 0.85

Calls 7

create_gitql_environmentFunction · 0.85
create_new_line_editorFunction · 0.85
execute_gitql_queryFunction · 0.85
report_diagnosticMethod · 0.80
clear_sessionMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…