Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcmicu committed Nov 6, 2024
1 parent 9e98d44 commit 40aab6e
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1231,13 +1231,23 @@ pub async fn move_row(cli: &Cli, table: &str, row: u32, after: u32) {
}

/// TODO: Add docstring
pub async fn undo_or_redo(cli: &Cli) {
pub async fn redo(cli: &Cli) {
let valve = build_valve(&cli).await;
let updated_row = match &cli.command {
Commands::Undo {} => valve.undo().await.expect("Error undoing"),
Commands::Redo {} => valve.redo().await.expect("Error redoing"),
_ => unreachable!(),
};
let updated_row = valve.redo().await.expect("Error redoing");
if let Some(valve_row) = updated_row {
print!(
"{}",
json!(valve_row
.to_rich_json()
.expect("Error converting row to rich JSON"))
);
}
}

/// TODO: Add docstring
pub async fn undo(cli: &Cli) {
let valve = build_valve(&cli).await;
let updated_row = valve.undo().await.expect("Error undoing");
if let Some(valve_row) = updated_row {
print!(
"{}",
Expand Down Expand Up @@ -1911,9 +1921,8 @@ pub async fn process_command() {
table,
} => load_table(&cli, table, *initial_load).await,
Commands::Move { table, row, after } => move_row(&cli, table, *row, *after).await,
Commands::Redo {} | Commands::Undo {} => {
undo_or_redo(&cli).await;
}
Commands::Redo {} => undo(&cli).await,
Commands::Undo {} => redo(&cli).await,
Commands::Rename { subcommand } => {
match subcommand {
RenameSubcommands::Column {
Expand Down

0 comments on commit 40aab6e

Please sign in to comment.