Skip to content

Commit

Permalink
feat(cpast): remove clipboard feature
Browse files Browse the repository at this point in the history
  • Loading branch information
rootCircle committed Oct 3, 2024
1 parent 4a7f07a commit 8342f1a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
/target

# Code coverage
lcov.info
/coverage
7 changes: 1 addition & 6 deletions cpast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,11 @@ default-run = "cpast"

[dependencies]
clap = { version = "4.5.16", features = ["derive"] }
cli-clipboard = { version = "0.4.0", optional = true }
cli-clipboard = { version = "0.4.0" }
tokio = { version = "1.40.0", features = ["full"] }
futures = "0.3.30"
colored = "2.1.0"
clap_complete = "4.5.32"
clex = { path = "../clex" }
ccode_runner = { path = "../ccode_runner" }

[features]
default = ["clipboard"]
clipboard = ["dep:cli-clipboard"]


4 changes: 1 addition & 3 deletions cpast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ cpast is pretty minimalistic by default, but to support basic CLI features like

We have first class support for macOS, Linux (GNOME, KDE, Hyprland) and Windows

Default compilations won't be supported due to lack of clipboard API support in those systems, and hence you need to compile it with `--no-default-features` feature

```bash
cargo install cpast --no-default-features
cargo install cpast
```

</details>
Expand Down
19 changes: 11 additions & 8 deletions cpast/src/cmd/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use std::process::exit;

use crate::cli::cli_parser::GenerateArgs;
use clex::generator;
#[cfg(feature = "clipboard")]
#[cfg(any(
all(unix, not(any(target_os = "android", target_os = "emscripten"))),
windows,
))]
use cli_clipboard::{ClipboardContext, ClipboardProvider};
use colored::Colorize;
use cpast::DEFAULT_FAIL_EXIT_CODE;
Expand Down Expand Up @@ -34,9 +37,9 @@ pub(crate) fn generate_call(args: GenerateArgs) {

#[allow(unused_variables)]
fn copy_content_to_clipboard(generated_testcases: String) {
#[cfg(all(
any(target_os = "windows", target_os = "linux", target_os = "macos"),
feature = "clipboard"
#[cfg(any(
all(unix, not(any(target_os = "android", target_os = "emscripten"))),
windows,
))]
{
let mut ctx = ClipboardContext::new().unwrap();
Expand All @@ -48,10 +51,10 @@ fn copy_content_to_clipboard(generated_testcases: String) {
println!("{}", "Copied to clipboard successfully!".green());
}

#[cfg(any(
not(any(target_os = "windows", target_os = "linux", target_os = "macos")),
not(feature = "clipboard")
))]
#[cfg(not(any(
all(unix, not(any(target_os = "android", target_os = "emscripten"))),
windows,
)))]
println!(
"{}",
"Clipboard Features not enabled during compilation/device not supported!".yellow()
Expand Down
6 changes: 3 additions & 3 deletions cpast/tests/clipboard_integration.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[test]
#[cfg(all(
any(target_os = "windows", target_os = "linux", target_os = "macos"),
feature = "clipboard"
#[cfg(any(
all(unix, not(any(target_os = "android", target_os = "emscripten"))),
windows,
))]
fn send_to_clipboard_works() {
use cli_clipboard::{ClipboardContext, ClipboardProvider};
Expand Down

0 comments on commit 8342f1a

Please sign in to comment.