summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/publish_image.yaml41
-rw-r--r--Earthfile7
-rw-r--r--README.md2
-rw-r--r--languages.json16
-rw-r--r--src/cli.rs1
-rw-r--r--src/cli_utils.rs21
-rw-r--r--src/config.rs1
-rw-r--r--src/main.rs11
-rw-r--r--tests/data/openscad.scad34
9 files changed, 116 insertions, 18 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/Earthfile b/Earthfile
index 5abf22d..998f71f 100644
--- a/Earthfile
+++ b/Earthfile
@@ -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
diff --git a/README.md b/README.md
index 9a27535..83889ca 100644
--- a/README.md
+++ b/README.md
@@ -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 d744a27..ac548b9 100644
--- a/languages.json
+++ b/languages.json
@@ -753,7 +753,7 @@
"Jinja2": {
"name": "Jinja2",
"blank": true,
- "extensions": ["j2"],
+ "extensions": ["j2", "jinja"],
"multi_line_comments": [["{#", "#}"]]
},
"Jq": {
@@ -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": ["#"],
diff --git a/src/cli.rs b/src/cli.rs
index afb1981..c21f9d8 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -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();