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

Method get_message

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

Get the commit message, potentially from editor.

(&self)

Source from the content-addressed store, hash-verified

114
115 /// Get the commit message, potentially from editor.
116 pub(super) fn get_message(&self) -> CliResult<String> {
117 // If message was provided, use it
118 if let Some(ref msg) = self.message {
119 return Ok(msg.clone());
120 }
121
122 // If edit flag is set or we're in a terminal without a message
123 if self.edit {
124 return self.get_message_from_editor();
125 }
126
127 // Check if stdin is a terminal
128 if is_terminal() {
129 // Interactive mode - prompt for message
130 print!("Enter commit message (empty line to cancel): ");
131 std::io::stdout().flush().map_err(|e| {
132 CliError::Internal(anyhow::anyhow!("Failed to flush stdout: {}", e))
133 })?;
134
135 let mut message = String::new();
136 std::io::stdin().read_line(&mut message).map_err(|e| {
137 CliError::Internal(anyhow::anyhow!("Failed to read message: {}", e))
138 })?;
139
140 let message = message.trim();
141 if message.is_empty() {
142 return Err(CliError::Cancelled);
143 }
144
145 Ok(message.to_string())
146 } else {
147 // Non-interactive mode - use default message
148 Ok("No message provided".to_string())
149 }
150 }
151
152 /// Open an editor to get the commit message.
153 pub(super) fn get_message_from_editor(&self) -> CliResult<String> {

Callers 1

runMethod · 0.45

Calls 5

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

Tested by

no test coverage detected