Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvements for interactive use #393

Merged
merged 11 commits into from
Oct 5, 2022
Merged

improvements for interactive use #393

merged 11 commits into from
Oct 5, 2022

Conversation

jayhesselberth
Copy link
Member

update testthat and tests

closes #392

update testthat and tests

closes #392
@jayhesselberth
Copy link
Member Author

still need to handle empty function calls, ideally these would use cli_abort(). :

library(valr)

# this error is partcularly uninformative
bed_intersect()
#> Error in y_tbl[[1]]: subscript out of bounds

bed_flank()
#> Error in check_interval(x): argument "x" is missing, with no default

bed_slop()
#> Error in check_interval(x): argument "x" is missing, with no default

Created on 2022-10-04 with reprex v2.0.2

@jayhesselberth
Copy link
Member Author

with new changes:

library(valr)

bed_intersect()
#> Error in `bed_intersect()`:
#> ! `x` is absent but must be supplied.

#> Backtrace:
#>     ▆
#>  1. └─valr::bed_intersect()
#>  2.   └─rlang::check_required(x) at valr/R/bed_intersect.r:90:2
#>  3.     └─rlang::abort(msg, call = call)

bed_flank()
#> Error in `bed_flank()`:
#> ! `x` is absent but must be supplied.

#> Backtrace:
#>     ▆
#>  1. └─valr::bed_flank()
#>  2.   └─rlang::check_required(x) at valr/R/bed_flank.r:58:2
#>  3.     └─rlang::abort(msg, call = call)

bed_slop()
#> Error in `bed_slop()`:
#> ! `x` is absent but must be supplied.

#> Backtrace:
#>     ▆
#>  1. └─valr::bed_slop()
#>  2.   └─rlang::check_required(x) at valr/R/bed_slop.r:50:2
#>  3.     └─rlang::abort(msg, call = call)

Created on 2022-10-04 with reprex v2.0.2

@jayhesselberth jayhesselberth changed the title use cli for msg/warn/info improvements for interactive use Oct 4, 2022
@jayhesselberth
Copy link
Member Author

behavior in pipes looks better now too:

library(valr)

x <- tibble::tribble(
  ~chrom, ~start, ~end,
  'chr1', 25,      50,
  'chr1', 100,     125
)

y <- tibble::tribble(
  ~chrom, ~start, ~end,
  'chr1', 30,     75
)

bed_intersect()
#> Error in `bed_intersect()`:
#> ! `x` is absent but must be supplied.

#> Backtrace:
#>     ▆
#>  1. └─valr::bed_intersect()
#>  2.   └─rlang::check_required(x) at valr/R/bed_intersect.r:90:2
#>  3.     └─rlang::abort(msg, call = call)

bed_intersect(x)
#> Error in `bed_intersect()`:
#> ! One or more tbls required in `...`

#> Backtrace:
#>     ▆
#>  1. └─valr::bed_intersect(x)
#>  2.   └─cli::cli_abort("One or more tbls required in {.var ...}") at valr/R/bed_intersect.r:93:4
#>  3.     └─rlang::abort(...)

bed_flank()
#> Error in `bed_flank()`:
#> ! `x` is absent but must be supplied.

#> Backtrace:
#>     ▆
#>  1. └─valr::bed_flank()
#>  2.   └─rlang::check_required(x) at valr/R/bed_flank.r:58:2
#>  3.     └─rlang::abort(msg, call = call)

bed_slop()
#> Error in `bed_slop()`:
#> ! `x` is absent but must be supplied.

#> Backtrace:
#>     ▆
#>  1. └─valr::bed_slop()
#>  2.   └─rlang::check_required(x) at valr/R/bed_slop.r:50:2
#>  3.     └─rlang::abort(msg, call = call)

# pipe behavior
bed_intersect(x, y) |>
  bed_flank()
#> Error in `bed_flank()`:
#> ! `genome` is absent but must be supplied.

#> Backtrace:
#>     ▆
#>  1. └─valr::bed_flank(bed_intersect(x, y))
#>  2.   └─rlang::check_required(genome) at valr/R/bed_flank.r:59:2
#>  3.     └─rlang::abort(msg, call = call)

Created on 2022-10-04 with reprex v2.0.2

Copy link
Member

@kriemo kriemo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the updates.

@jayhesselberth jayhesselberth merged commit 4b9c506 into main Oct 5, 2022
@jayhesselberth jayhesselberth deleted the cli-update branch October 5, 2022 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

update message and errors with cli
2 participants