Skip to content

no rust error msg and intro for pkg style printout #26

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

Merged
merged 14 commits into from
Jan 27, 2025

Conversation

Polkas
Copy link
Collaborator

@Polkas Polkas commented Jan 25, 2025

We return a list not a string for format_code, the first list element is a status.

PS. We not want to use |> as it implies we expect at least R 4.1

Add a prototype nice style_pkg printout, I will polish it

extendr-wrappers.R ✔
styling.R ❌ : Failed to style the file.
tergo.R ✔
configure.R ✔
update_authors.R ✔

Summary:
  ▶ Files processed : 5
  ✔ Successful     : 4
  ❌ Failed         : 1

package_root <- dirname(package_root)
if (strsplit(package_root, split = .Platform$file.sep) |> length() == 1) {
parent_dir <- dirname(package_root)
if (parent_dir == package_root) { # Reached root without finding DESCRIPTION
Copy link
Owner

Choose a reason for hiding this comment

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

Will this comparison behave nicely on Windows? I wouldn't want people to need to create two different styling scripts for Windows and Unix platforms because of backwards slashes.

# Format

# Define ANSI Color Codes and Unicode Symbols
green_tick <- "\u001B[32m\u2714\u001B[0m"
Copy link
Owner

Choose a reason for hiding this comment

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

METAL

#'
#' @export
style_pkg <- function(path = ".",
config_file = "tergo.toml",
configuration = list(),
force = FALSE,
extensions = c(".R", ".r")) {
extensions = c(".R", ".r"),
verbose = interactive()) {
Copy link
Owner

Choose a reason for hiding this comment

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

Clever.

kpagacz
kpagacz previously approved these changes Jan 27, 2025
@@ -72,7 +72,15 @@ fn format_code(source_code: &str, configuration: extendr_api::List) -> String {
.unwrap_or(default_config.insert_newline_in_quote_call.0),
);

tergo_lib::tergo_format(source_code, Some(&config)).unwrap()

match tergo_lib::tergo_format(source_code, Some(&config)) {
Copy link
Owner

Choose a reason for hiding this comment

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

BTW, the issue of panics stemming from wrong configuration values still persists. It's all lines 15-75.

@Polkas Polkas merged commit f3ee101 into kpagacz:main Jan 27, 2025
11 checks passed
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.

Improve error message for wrong code Consider adding some check stats
2 participants