Skip to content

Commit

Permalink
Rename migrate command to import as per suggestion in https://news.yc…
Browse files Browse the repository at this point in the history
…ombinator.com/item?id=41208723

@philippgille sorry for the late reply, totally forgot HN doesn't send reply notifications. As to your first question around the naming of the repo, I created it before I came up with the name. That said I have added a redirect from supercilex/ringboard.
  • Loading branch information
Alex Saveau committed Oct 26, 2024
1 parent c77db57 commit a91365f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
10 changes: 5 additions & 5 deletions cli/command-reference-short.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Commands:
swap Swap the positions of two entries
remove Delete an entry from the database
wipe Wipe the entire database
migrate Migrate from other clipboard managers to Ringboard
import Migrate from other clipboard managers to Ringboard
garbage-collect Run garbage collection on the database
configure Modify app settings
debug Debugging tools for developers
Expand Down Expand Up @@ -136,10 +136,10 @@ Options:

Migrate from other clipboard managers to Ringboard

Usage: clipboard-history migrate <FROM> [DATABASE]
Usage: clipboard-history import <FROM> [DATABASE]

Arguments:
<FROM> The existing clipboard to migrate from [possible values: gnome-clipboard-history,
<FROM> The existing clipboard to import [possible values: gnome-clipboard-history,
clipboard-indicator, g-paste, json]
[DATABASE] The existing clipboard's database location

Expand Down Expand Up @@ -323,7 +323,7 @@ Commands:
swap Swap the positions of two entries
remove Delete an entry from the database
wipe Wipe the entire database
migrate Migrate from other clipboard managers to Ringboard
import Migrate from other clipboard managers to Ringboard
garbage-collect Run garbage collection on the database
configure Modify app settings
debug Debugging tools for developers
Expand Down Expand Up @@ -387,7 +387,7 @@ Usage: clipboard-history help wipe

Migrate from other clipboard managers to Ringboard

Usage: clipboard-history help migrate
Usage: clipboard-history help import

---

Expand Down
12 changes: 6 additions & 6 deletions cli/command-reference.golden
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Commands:
swap Swap the positions of two entries
remove Delete an entry from the database
wipe Wipe the entire database
migrate Migrate from other clipboard managers to Ringboard
import Migrate from other clipboard managers to Ringboard
garbage-collect Run garbage collection on the database
configure Modify app settings
debug Debugging tools for developers
Expand Down Expand Up @@ -187,11 +187,11 @@ Options:

Migrate from other clipboard managers to Ringboard

Usage: clipboard-history migrate <FROM> [DATABASE]
Usage: clipboard-history import <FROM> [DATABASE]

Arguments:
<FROM>
The existing clipboard to migrate from
The existing clipboard to import

Possible values:
- gnome-clipboard-history: [Gnome Clipboard
Expand Down Expand Up @@ -324,7 +324,7 @@ The JSON format is as follows:
...
]

Note that `$ ringboard migrate json` expects a JSON stream (wherein each object appears on its own
Note that `$ ringboard import json` expects a JSON stream (wherein each object appears on its own
line instead of being in a list). To import an export, you can convert the JSON array to a stream
with `$ ... | jq -c .[]`.

Expand Down Expand Up @@ -446,7 +446,7 @@ Commands:
swap Swap the positions of two entries
remove Delete an entry from the database
wipe Wipe the entire database
migrate Migrate from other clipboard managers to Ringboard
import Migrate from other clipboard managers to Ringboard
garbage-collect Run garbage collection on the database
configure Modify app settings
debug Debugging tools for developers
Expand Down Expand Up @@ -510,7 +510,7 @@ Usage: clipboard-history help wipe

Migrate from other clipboard managers to Ringboard

Usage: clipboard-history help migrate
Usage: clipboard-history help import

---

Expand Down
27 changes: 13 additions & 14 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ enum Cmd {
Wipe,

/// Migrate from other clipboard managers to Ringboard.
Migrate(Migrate),
#[command(alias = "migrate")]
Import(Import),

/// Run garbage collection on the database.
///
Expand Down Expand Up @@ -197,7 +198,7 @@ enum Dev {
///{n} ...
///{n}]
///
/// Note that `$ ringboard migrate json` expects a JSON stream (wherein each
/// Note that `$ ringboard import json` expects a JSON stream (wherein each
/// object appears on its own line instead of being in a list). To import an
/// export, you can convert the JSON array to a stream with `$ ... | jq -c
/// .[]`.
Expand Down Expand Up @@ -287,11 +288,11 @@ struct Swap {

#[derive(Args, Debug)]
#[command(arg_required_else_help = true)]
struct Migrate {
/// The existing clipboard to migrate from.
struct Import {
/// The existing clipboard to import.
#[arg(required = true)]
#[arg(requires_if("json", "database"))]
from: MigrateFromClipboard,
from: ImportClipboard,

/// The existing clipboard's database location.
///
Expand All @@ -301,7 +302,7 @@ struct Migrate {
}

#[derive(ValueEnum, Copy, Clone, Debug)]
enum MigrateFromClipboard {
enum ImportClipboard {
/// [Gnome Clipboard History](https://extensions.gnome.org/extension/4839/clipboard-history/)
#[value(alias = "gch")]
GnomeClipboardHistory,
Expand Down Expand Up @@ -467,7 +468,7 @@ fn run() -> Result<(), CliError> {
Cmd::Remove(data) => remove(connect_to_server(&server_addr)?, data),
Cmd::Wipe => wipe(),
Cmd::GarbageCollect(data) => garbage_collect(connect_to_server(&server_addr)?, data),
Cmd::Migrate(data) => migrate(connect_to_server(&server_addr)?, data),
Cmd::Import(data) => import(connect_to_server(&server_addr)?, data),
Cmd::Configure(Configure::X11(data)) => configure_x11(data),
Cmd::Debug(Dev::Stats) => stats(),
Cmd::Debug(Dev::Dump) => dump(),
Expand Down Expand Up @@ -819,14 +820,12 @@ fn garbage_collect(
Ok(())
}

fn migrate(server: OwnedFd, Migrate { from, database }: Migrate) -> Result<(), CliError> {
fn import(server: OwnedFd, Import { from, database }: Import) -> Result<(), CliError> {
match from {
MigrateFromClipboard::GnomeClipboardHistory => migrate_from_gch(server, database),
MigrateFromClipboard::ClipboardIndicator => {
migrate_from_clipboard_indicator(server, database)
}
MigrateFromClipboard::GPaste => migrate_from_gpaste(server, database),
MigrateFromClipboard::Json => migrate_from_ringboard_export(server, database.unwrap()),
ImportClipboard::GnomeClipboardHistory => migrate_from_gch(server, database),
ImportClipboard::ClipboardIndicator => migrate_from_clipboard_indicator(server, database),
ImportClipboard::GPaste => migrate_from_gpaste(server, database),
ImportClipboard::Json => migrate_from_ringboard_export(server, database.unwrap()),
}?;
println!("Migration complete.");
Ok(())
Expand Down

0 comments on commit a91365f

Please sign in to comment.