Skip to content

Commit 9dde123

Browse files
authored
Support file paths in CLI positional argument (#16)
* begin pre-commit support * deserialize CLI options into structs from parsed results
1 parent c7ae257 commit 9dde123

File tree

15 files changed

+382
-229
lines changed

15 files changed

+382
-229
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
*.code-workspace text eol=lf
2626
*.clang-tidy text eol=lf
2727
*.clang-format text eol=lf
28+
justfile text eol=lf

cpp-linter-lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ documentation.workspace = true
88
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
99

1010
[dependencies]
11-
clap = { version = "4.5.16" }
11+
clap = "4.5.16"
1212
git2 = "0.19.0"
1313
lenient_semver = "0.4.2"
1414
log = "0.4.22"

cpp-linter-lib/README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22
# cpp-linter-lib
33

44
This crate contains the the library used as a backend for the
5-
`cpp-linter` binary executable.
5+
`cpp-linter` binary executable. The main focus of `cpp-linter` is as follows:
6+
7+
- [x] Lint C/C++ sources using clang-format and clang-tidy.
8+
- [x] Respect file changes when run in a CI workflow on Github.
9+
- [x] Provide feedback via Github's REST API in the any of the following forms:
10+
- [x] step summary
11+
- [x] thread comments
12+
- [x] file annotation
13+
- [ ] pull request review suggestions
614

715
Since the [cpp-linter python package][pypi-org] now uses this library
8-
as a binding, the native binary's `main()` method is also present in this
9-
library.
16+
as a binding, the native binary's `main()` behavior is also present in this
17+
library (see `run::run_main()`).
1018

1119
See also the [CLI document hosted on github][gh-pages].
1220

cpp-linter-lib/examples/gh_rest_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
1414
let client_controller = GithubApiClient::new();
1515

1616
let file_filter = FileFilter::new(
17-
&["target", ".github"],
17+
&["target".to_string(), ".github".to_string()],
1818
vec!["cpp".to_string(), "hpp".to_string()],
1919
);
2020

cpp-linter-lib/src/clang_tools/mod.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ use which::{which, which_in};
1818
// project-specific modules/crates
1919
use super::common_fs::FileObj;
2020
use crate::{
21-
cli::LinesChangedOnly,
22-
common_fs::FileFilter,
21+
cli::ClangParams,
2322
logger::{end_log_group, start_log_group},
2423
};
2524
pub mod clang_format;
@@ -77,20 +76,6 @@ pub fn get_clang_tool_exe(name: &str, version: &str) -> Result<PathBuf, &'static
7776
}
7877
}
7978

80-
#[derive(Debug, Clone)]
81-
pub struct ClangParams {
82-
pub tidy_checks: String,
83-
pub lines_changed_only: LinesChangedOnly,
84-
pub database: Option<PathBuf>,
85-
pub extra_args: Option<Vec<String>>,
86-
pub database_json: Option<CompilationDatabase>,
87-
pub style: String,
88-
pub clang_tidy_command: Option<PathBuf>,
89-
pub clang_format_command: Option<PathBuf>,
90-
pub tidy_filter: FileFilter,
91-
pub format_filter: FileFilter,
92-
}
93-
9479
/// This creates a task to run clang-tidy and clang-format on a single file.
9580
///
9681
/// Returns a Future that infallibly resolves to a 2-tuple that contains

0 commit comments

Comments
 (0)