MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / get_message

Method get_message

atomic-cli/src/commands/record/builder.rs:170–204  ·  view source on GitHub ↗

Get the commit message, potentially from editor. Shared by the local body and the service-layer hook: the editor and the interactive prompt are client-side by design, so the routed path composes the message with this SAME code and sends it on the wire.

(&self)

Source from the content-addressed store, hash-verified

168 /// the interactive prompt are client-side by design, so the routed path
169 /// composes the message with this SAME code and sends it on the wire.
170 pub(crate) fn get_message(&self) -> CliResult<String> {
171 // If message was provided, use it
172 if let Some(ref msg) = self.message {
173 return Ok(msg.clone());
174 }
175
176 // If edit flag is set or we're in a terminal without a message
177 if self.edit {
178 return self.get_message_from_editor();
179 }
180
181 // Check if stdin is a terminal
182 if is_terminal() {
183 // Interactive mode - prompt for message
184 print!("Enter commit message (empty line to cancel): ");
185 std::io::stdout().flush().map_err(|e| {
186 CliError::Internal(anyhow::anyhow!("Failed to flush stdout: {}", e))
187 })?;
188
189 let mut message = String::new();
190 std::io::stdin().read_line(&mut message).map_err(|e| {
191 CliError::Internal(anyhow::anyhow!("Failed to read message: {}", e))
192 })?;
193
194 let message = message.trim();
195 if message.is_empty() {
196 return Err(CliError::Cancelled);
197 }
198
199 Ok(message.to_string())
200 } else {
201 // Non-interactive mode - use default message
202 Ok("No message provided".to_string())
203 }
204 }
205
206 /// Open an editor to get the commit message.
207 pub(super) fn get_message_from_editor(&self) -> CliResult<String> {

Callers 1

runMethod · 0.45

Calls 6

is_terminalFunction · 0.85
stdoutFunction · 0.85
cloneMethod · 0.45
flushMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected