Skip to content

Commit

Permalink
Migrate to GitQL SDK 0.28.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AmrDeveloper committed Sep 28, 2024
1 parent ff36111 commit 001113e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 63 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ categories = ["command-line-utilities"]
exclude = [".github/**", "docs/**", "media/**", "scripts/**"]

[dependencies]
gitql-core = "0.4.0"
gitql-std = "0.4.1"
gitql-cli = "0.27.0"
gitql-ast = "0.24.0"
gitql-parser = "0.26.0"
gitql-engine = "0.27.0"
gitql-core = "0.5.0"
gitql-std = "0.5.0"
gitql-cli = "0.28.0"
gitql-ast = "0.25.0"
gitql-parser = "0.27.0"
gitql-engine = "0.28.0"
atty = "0.2.14"
47 changes: 2 additions & 45 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,60 +186,17 @@ fn execute_fileql_query(

// Render the result only if they are selected groups not any other statement
let engine_result = evaluation_result.ok().unwrap();
if let SelectedGroups(mut groups, hidden_selection) = engine_result {
if let SelectedGroups(mut groups) = engine_result {
match arguments.output_format {
OutputFormat::Render => {
render::render_objects(
&mut groups,
&hidden_selection,
arguments.pagination,
arguments.page_size,
);
render::render_objects(&mut groups, arguments.pagination, arguments.page_size);
}
OutputFormat::JSON => {
let mut indexes = vec![];
for (index, title) in groups.titles.iter().enumerate() {
if hidden_selection.contains(title) {
indexes.insert(0, index);
}
}

if groups.len() > 1 {
groups.flat()
}

for index in indexes {
groups.titles.remove(index);

for row in &mut groups.groups[0].rows {
row.values.remove(index);
}
}

if let Ok(json) = groups.as_json() {
println!("{}", json);
}
}
OutputFormat::CSV => {
let mut indexes = vec![];
for (index, title) in groups.titles.iter().enumerate() {
if hidden_selection.contains(title) {
indexes.insert(0, index);
}
}

if groups.len() > 1 {
groups.flat()
}

for index in indexes {
groups.titles.remove(index);

for row in &mut groups.groups[0].rows {
row.values.remove(index);
}
}

if let Ok(csv) = groups.as_csv() {
println!("{}", csv);
}
Expand Down

0 comments on commit 001113e

Please sign in to comment.