diff options
-rw-r--r-- | .github/workflows/publish_image.yaml | 41 | ||||
-rw-r--r-- | CHANGELOG.md | 36 | ||||
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Earthfile | 7 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | languages.json | 14 | ||||
-rw-r--r-- | src/cli.rs | 1 | ||||
-rw-r--r-- | src/cli_utils.rs | 21 | ||||
-rw-r--r-- | src/config.rs | 1 | ||||
-rw-r--r-- | src/main.rs | 11 | ||||
-rw-r--r-- | tests/data/openscad.scad | 34 |
12 files changed, 153 insertions, 19 deletions
diff --git a/.github/workflows/publish_image.yaml b/.github/workflows/publish_image.yaml new file mode 100644 index 0000000..115eb42 --- /dev/null +++ b/.github/workflows/publish_image.yaml @@ -0,0 +1,41 @@ +name: Publish Docker Images + +on: + push: + branches: + - master + tags: + - v* + +jobs: + image: + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + attestations: write + steps: + - uses: earthly/actions-setup@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Check out the repo + uses: actions/checkout@v4 + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=semver,pattern={{raw}} + type=raw,value=latest,enable={{is_default_branch}} + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and Push Docker Image + run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} earthly --ci --push +docker --image_name="{}" diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aeda7e..7255215 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [13.0.0-alpha.2](https://github.com/XAMPPRocky/tokei/compare/v13.0.0-alpha.1...v13.0.0-alpha.2) - 2024-05-13 + +### Added +- --files argument now sorts alphabetically ([#1059](https://github.com/XAMPPRocky/tokei/pull/1059)) +- add support for LALRPOP ([#1077](https://github.com/XAMPPRocky/tokei/pull/1077)) + +### Fixed +- read hidden from config file ([#1093](https://github.com/XAMPPRocky/tokei/pull/1093)) + +### Other +- GitHub Action to publish docker images ([#1096](https://github.com/XAMPPRocky/tokei/pull/1096)) +- Support MoonBit language. ([#1095](https://github.com/XAMPPRocky/tokei/pull/1095)) +- Add OpenSCAD ([#1097](https://github.com/XAMPPRocky/tokei/pull/1097)) +- add jinja extension for Jinja2 ([#1083](https://github.com/XAMPPRocky/tokei/pull/1083)) +- Fix slang ([#1089](https://github.com/XAMPPRocky/tokei/pull/1089)) +- Temporarily remove Hare +- Support .pyi python file ([#1075](https://github.com/XAMPPRocky/tokei/pull/1075)) +- add luau extension to lua ([#1066](https://github.com/XAMPPRocky/tokei/pull/1066)) +- Adding support for Snakemake ([#1045](https://github.com/XAMPPRocky/tokei/pull/1045)) +- Add Janet to languages.json ([#1042](https://github.com/XAMPPRocky/tokei/pull/1042)) +- Add OpenQASM support ([#1041](https://github.com/XAMPPRocky/tokei/pull/1041)) +- typst ([#1037](https://github.com/XAMPPRocky/tokei/pull/1037)) +- Add the ZoKrates language ([#1035](https://github.com/XAMPPRocky/tokei/pull/1035)) +- Add PRQL ([#1030](https://github.com/XAMPPRocky/tokei/pull/1030)) +- remove refs ([#1006](https://github.com/XAMPPRocky/tokei/pull/1006)) +- Add lingua franca language ([#993](https://github.com/XAMPPRocky/tokei/pull/993)) +- Add support for Razor Components ([#992](https://github.com/XAMPPRocky/tokei/pull/992)) +- Add arch's PKGBUILD files ([#972](https://github.com/XAMPPRocky/tokei/pull/972)) +- Add Hare support ([#971](https://github.com/XAMPPRocky/tokei/pull/971)) +- Add Max support ([#963](https://github.com/XAMPPRocky/tokei/pull/963)) +- Add support for Chapel ([#960](https://github.com/XAMPPRocky/tokei/pull/960)) +- Add language support for Slang ([#956](https://github.com/XAMPPRocky/tokei/pull/956)) +- Update TypeScript language ([#953](https://github.com/XAMPPRocky/tokei/pull/953)) +- Added support for Circom ([#949](https://github.com/XAMPPRocky/tokei/pull/949)) +- link to earthly project ([#1078](https://github.com/XAMPPRocky/tokei/pull/1078)) + ## [13.0.0-alpha.1](https://github.com/XAMPPRocky/tokei/compare/v13.0.0-alpha.0...v13.0.0-alpha.1) - 2024-03-04 ### Fixed @@ -1447,7 +1447,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokei" -version = "13.0.0-alpha.1" +version = "13.0.0-alpha.2" dependencies = [ "aho-corasick", "arbitrary", @@ -19,7 +19,7 @@ license = "MIT/Apache-2.0" name = "tokei" readme = "README.md" repository = "https://github.com/XAMPPRocky/tokei.git" -version = "13.0.0-alpha.1" +version = "13.0.0-alpha.2" [features] all = ["cbor", "yaml"] @@ -1,9 +1,9 @@ VERSION 0.6 -FROM alpine:3.14 +FROM alpine:3.19 WORKDIR /src build: - FROM rust:alpine3.14 + FROM rust:alpine3.19 RUN apk update \ && apk add \ git \ @@ -21,4 +21,5 @@ docker: WORKDIR /src ENTRYPOINT [ "tokei" ] CMD [ "--help" ] - SAVE IMAGE tokei + ARG image_name=tokei:latest + SAVE IMAGE --push $image_name @@ -6,6 +6,7 @@ ![](https://img.shields.io/crates/d/tokei?label=downloads%20%28crates.io%29)
![](https://img.shields.io/github/downloads/xampprocky/tokei/total?label=downloads%20%28GH%29)
![](https://img.shields.io/homebrew/installs/dy/tokei?color=brightgreen&label=downloads%20%28brew%29)
+[![dependency status](https://deps.rs/repo/github/XAMPPRocky/tokei/status.svg)](https://deps.rs/repo/github/XAMPPRocky/tokei)
Tokei is a program that displays statistics about your code. Tokei will show the number of files, total lines within those files and code, comments, and blanks grouped by language.
@@ -464,6 +465,7 @@ ObjectiveC ObjectiveCpp
OCaml
Odin
+OpenSCAD
OpenQASM
Org
Oz
diff --git a/languages.json b/languages.json index 977655b..ac548b9 100644 --- a/languages.json +++ b/languages.json @@ -966,6 +966,11 @@ "extensions": ["def"], "line_comment": [";"] }, + "MoonBit": { + "line_comment": ["//"], + "quotes": [["\\\"", "\\\""]], + "extensions": ["mbt"] + }, "MoonScript": { "line_comment": ["--"], "quotes": [["\\\"", "\\\""], ["'", "'"]], @@ -1045,6 +1050,13 @@ "multi_line_comments": [["/*", "*/"]], "quotes": [["\\\"", "\\\""], ["'", "'"]] }, + "OpenScad": { + "name": "OpenSCAD", + "extensions": ["scad"], + "line_comment": ["//"], + "multi_line_comments": [["/*", "*/"]], + "quotes": [["\\\"", "\\\""], ["'", "'"]] + }, "OpenPolicyAgent": { "name": "Open Policy Agent", "line_comment": ["#"], @@ -1076,7 +1088,7 @@ "name": "Pacman's makepkg", "line_comment": ["#"], "quotes": [["\\\"", "\\\""], ["'", "'"]], - "filenames": ["pkgbuild"] + "filenames": ["pkgbuild"] }, "Pan": { "line_comment": ["#"], @@ -370,6 +370,7 @@ impl Cli { /// higher precedence than options present in config files. /// /// #### Shared options + /// * `hidden` /// * `no_ignore` /// * `no_ignore_parent` /// * `no_ignore_dot` diff --git a/src/cli_utils.rs b/src/cli_utils.rs index 9d9e730..4112e33 100644 --- a/src/cli_utils.rs +++ b/src/cli_utils.rs @@ -312,7 +312,12 @@ impl<W: Write> Printer<W> { Ok(()) } - pub fn print_results<'a, I>(&mut self, languages: I, compact: bool) -> io::Result<()> + pub fn print_results<'a, I>( + &mut self, + languages: I, + compact: bool, + is_sorted: bool, + ) -> io::Result<()> where I: Iterator<Item = (&'a LanguageType, &'a Language)>, { @@ -337,16 +342,18 @@ impl<W: Write> Printer<W> { if self.list_files { self.print_subrow()?; - + let mut reports: Vec<&Report> = + language.reports.iter().map(|report| &*report).collect(); + if !is_sorted { + reports.sort_by(|&a, &b| a.name.cmp(&b.name)); + } if compact { - for report in &language.reports { + for &report in &reports { writeln!(self.writer, "{:1$}", report, self.path_length)?; } } else { - let (a, b): (Vec<_>, Vec<_>) = language - .reports - .iter() - .partition(|r| r.stats.blobs.is_empty()); + let (a, b): (Vec<&Report>, Vec<&Report>) = + reports.iter().partition(|&r| r.stats.blobs.is_empty()); for reports in &[&a, &b] { let mut first = true; for report in reports.iter() { diff --git a/src/config.rs b/src/config.rs index 33687b7..1dfe5ff 100644 --- a/src/config.rs +++ b/src/config.rs @@ -113,6 +113,7 @@ impl Config { columns: current_dir .columns .or(home_dir.columns.or(conf_dir.columns)), + hidden: current_dir.hidden.or(home_dir.hidden.or(conf_dir.hidden)), //languages: current_dir.languages.or(conf_dir.languages), treat_doc_strings_as_comments: current_dir.treat_doc_strings_as_comments.or(home_dir .treat_doc_strings_as_comments diff --git a/src/main.rs b/src/main.rs index b8a3f33..dd7b3a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,6 @@ fn main() -> Result<(), Box<dyn Error>> { Cli::print_supported_languages()?; process::exit(0); } - let config = cli.override_config(Config::from_config_files()); let mut languages = Languages::new(); @@ -94,13 +93,13 @@ fn main() -> Result<(), Box<dyn Error>> { printer.print_header()?; + let mut is_sorted = false; if let Some(sort_category) = cli.sort.or(config.sort) { for (_, ref mut language) in &mut languages { language.sort_by(sort_category); } let mut languages: Vec<_> = languages.iter().collect(); - match sort_category { Sort::Blanks => languages.sort_by(|a, b| b.1.blanks.cmp(&a.1.blanks)), Sort::Comments => languages.sort_by(|a, b| b.1.comments.cmp(&a.1.comments)), @@ -108,14 +107,14 @@ fn main() -> Result<(), Box<dyn Error>> { Sort::Files => languages.sort_by(|a, b| b.1.reports.len().cmp(&a.1.reports.len())), Sort::Lines => languages.sort_by(|a, b| b.1.lines().cmp(&a.1.lines())), } - + is_sorted = true; if cli.sort_reverse { - printer.print_results(languages.into_iter().rev(), cli.compact)?; + printer.print_results(languages.into_iter().rev(), cli.compact, is_sorted)?; } else { - printer.print_results(languages.into_iter(), cli.compact)?; + printer.print_results(languages.into_iter(), cli.compact, is_sorted)?; } } else { - printer.print_results(languages.iter(), cli.compact)?; + printer.print_results(languages.iter(), cli.compact, is_sorted)?; } printer.print_total(&languages)?; diff --git a/tests/data/openscad.scad b/tests/data/openscad.scad new file mode 100644 index 0000000..88f3665 --- /dev/null +++ b/tests/data/openscad.scad @@ -0,0 +1,34 @@ +//! 34 lines 15 code 16 comments 3 blanks +// https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Commented_Example_Projects +// The idea is to twist a translated circle: +// - +/* + linear_extrude(height = 10, twist = 360, scale = 0) + translate([1,0]) + circle(r = 1); +*/ + +module horn(height = 10, radius = 6, + twist = 720, $fn = 50) +{ + // A centered circle translated by 1xR and + // twisted by 360° degrees, covers a 2x(2xR) space. + // - + radius = radius/4; + // De-translate. + // - + translate([-radius,0]) + // The actual code. + // - + linear_extrude(height = height, twist = twist, + scale=0, $fn = $fn) + translate([radius,0]) + circle(r=radius); +} + +translate([3,0]) +mirror() +horn(); + +translate([-3,0]) +horn(); |