Skip to content

Commit 3bac701

Browse files
authored
Merge pull request #104 from r-world-devs/maciekbanas/43/add-print-method-to-gitai-object
Prettify printing of the GitAI object.
2 parents 2444c04 + bc288bd commit 3bac701

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: GitAI
22
Title: Extracts Knowledge From Git Repositories
3-
Version: 0.0.0.9017
3+
Version: 0.0.0.9018
44
Authors@R: c(
55
person("Kamil", "Wais", , "[email protected]", role = c("aut", "cre")),
66
person("Krystian", "Igras", , "[email protected]", role = "aut"),

R/GitAI.R

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ GitAI <- R6::R6Class(
44
initialize = function(project_id) {
55

66
private$.project_id <- project_id
7+
},
8+
9+
print = function() {
10+
cat(cli::style_bold("A ", cli::col_yellow("GitAI"), " object: \n"))
11+
private$print_project_id()
12+
private$print_files()
13+
private$print_llm_data()
14+
private$print_db_data()
715
}
816
),
917

@@ -56,6 +64,37 @@ GitAI <- R6::R6Class(
5664
.gitstats = NULL,
5765
.files = NULL,
5866
.repos_metadata = NULL,
59-
.files_content = NULL
67+
.files_content = NULL,
68+
69+
print_project_id = function() {
70+
cat(cli::col_br_yellow("Project ID:"), private$.project_id, "\n")
71+
},
72+
73+
print_files = function() {
74+
if (is.null(private$.files)) {
75+
cat(cli::col_br_yellow("Files:"), cli::col_grey("not added"), "\n")
76+
} else {
77+
cat(cli::col_br_yellow("Files:"),
78+
paste0(private$.files, collapse = ", ")
79+
, "\n")
80+
}
81+
},
82+
83+
print_llm_data = function() {
84+
if (is.null(private$.llm)) {
85+
cat(cli::col_br_yellow("LLM:"), cli::col_grey("not set"), "\n")
86+
} else {
87+
cat(cli::col_br_yellow("LLM:"), "set", "\n")
88+
}
89+
},
90+
91+
print_db_data = function() {
92+
if (is.null(private$.db)) {
93+
cat(cli::col_br_yellow("Database:"), cli::col_grey("not set"), "\n")
94+
} else {
95+
browser()
96+
cat(cli::col_br_yellow("Database:"), "set", "\n")
97+
}
98+
}
6099
)
61100
)

0 commit comments

Comments
 (0)