Skip to content

Automatic cumulative usage script#82

Open
TheFreeman193 wants to merge 3 commits into
ebelinski:mainfrom
TheFreeman193:add-usage-auto-update
Open

Automatic cumulative usage script#82
TheFreeman193 wants to merge 3 commits into
ebelinski:mainfrom
TheFreeman193:add-usage-auto-update

Conversation

@TheFreeman193

Copy link
Copy Markdown
Contributor

Adds a PowerShell script for automatically fetching usage data, calculating cumulative usage, and updating the homepage markdown.

The script will work with PowerShell 7 on any platform and Windows PowerShell. It defaults to using the previous month as the range end date, but can accept any month.

The script also updates the footnote with the data source month and update date.

Usage:

pwsh -File meta/android-usage-generator.ps1 [-JustPrint] [-Month <YYYY-MM>]
  • -JustPrint will output cumulative usage to the console without modifying index.md
  • -Month YYYY-MM allows a custom range end to be chosen

The hardcoded relative path to index.md and default month are intended to make it easier for others to run the script and for any future automation.

- Rename old usage generators to meta/old_*
- Simplify meta/android-usage-generator.ps1, update for A16
- Add Unlicense and documentation to meta/android-usage-generator.ps1
- Update cumulative usage to January 2026
@TWiStErRob

Copy link
Copy Markdown
Collaborator

If we rewrite the script, it feels like for an Android based project, the most appropriate would be a Kotlin script... but I'll let @ebelinski decide.

Few examples with networking and serialisation: https://github.com/search?q=repo%3ATWiStErRob%2FTWiStErRob-env+path%3Akts&type=code

@TheFreeman193

Copy link
Copy Markdown
Contributor Author

If we rewrite the script, it feels like for an Android based project, the most appropriate would be a Kotlin script... but I'll let @ebelinski decide.

Few examples with networking and serialisation: https://github.com/search?q=repo%3ATWiStErRob%2FTWiStErRob-env+path%3Akts&type=code

I'd be happy to rewrite it in whatever language is deemed appropriate, but Kotlin is not a scripting language, so we'd either need to keep the compiled binary (be that JVM bytecode or a native app via LLVM) in the repo for others to run, transpile to JS, or have contributors compile it with kotlinc every time they wanted to update the usage stats.

It just seems like that would be overcomplicating things versus an interpreted scripting language like Python, PowerShell, Lua etc.

@TWiStErRob

TWiStErRob commented Feb 3, 2026

Copy link
Copy Markdown
Collaborator

Kotlin is a scripting language..., can run it directly with: kotlin foo.main.kts or even ./foo.main.kts if it starts with a shebang. It's just not well documented, most examples I find are complicated custom definitions, but the built-in .main.kts are trival, official examples: https://github.com/Kotlin/kotlin-script-examples/blob/master/jvm/main-kts/MainKts.md

It can pull in Maven dependencies, so it's all totally familiar to Android devs. Anyway, let's see what the owner says.

(Just as an extra thing that blew my mind, you can write GitHub Actions steps in Kotlin too: https://github.com/TWiStErRob/github-actions-test/blob/main/.github/workflows/scripting.yml#L8-L23)

@TheFreeman193

Copy link
Copy Markdown
Contributor Author

Kotlin is a scripting language..., can run it directly with: kotlin foo.main.kts or even ./foo.main.kts if it starts with a shebang. It's just not well documented, most examples I find are complicated custom definitions, but the built-in .main.kts are trival, official examples: https://github.com/Kotlin/kotlin-script-examples/blob/master/jvm/main-kts/MainKts.md

It can pull in Maven dependencies, so it's all totally familiar to Android devs. Anyway, let's see what the owner says.

(Just as an extra thing that blew my mind, you can write GitHub Actions steps in Kotlin too: https://github.com/TWiStErRob/github-actions-test/blob/main/.github/workflows/scripting.yml#L8-L23)

I've never seen Kotlin used that way - pretty neat.

I was aware of the Actions support for arbitrary shells (and I use PowerShell more than I should) but again had no idea Kotlin has a command line interpreter built in!

@marcprux

Copy link
Copy Markdown

I've never seen Kotlin used that way - pretty neat.

One very prominent use of Kotlin scripting is Gradle's syntax modernization for build.gradle.kts: https://docs.gradle.org/current/userguide/kotlin_dsl.html#sec:scripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants