runcom

A XDG enhanced run command manager for command line interfaces.

https://github.com/bkuhlmann/runcom

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.3%) to scientific vocabulary

Keywords

cli configuration-management runcom xdg
Last synced: 4 months ago · JSON representation ·

Repository

A XDG enhanced run command manager for command line interfaces.

Basic Info
Statistics
  • Stars: 18
  • Watchers: 2
  • Forks: 1
  • Open Issues: 0
  • Releases: 0
Topics
cli configuration-management runcom xdg
Created about 9 years ago · Last pushed 4 months ago
Metadata Files
Readme Funding License Citation

README.adoc

:toc: macro
:toclevels: 5
:figure-caption!:

:xdg_link: link:https://alchemists.io/projects/xdg[XDG]
:etcher_link: link:https://alchemists.io/projects/etcher[Etcher]

= Runcom

Runcom is a link:https://en.wikipedia.org/wiki/Run_commands[Run Command] portmanteau (i.e. `run + [com]mand = runcom`) which provides common functionality for Command Line Interfaces (CLIs) in which to manage global/local caches, configurations, data, and/or state. This is done by leveraging the https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html[XDG Base Directory Specification] built atop the {xdg_link} implementation. In other words, Runcom is an enhanced version of {xdg_link} which specializes in dynamic global and local detection.

toc::[]

== Features

* Wraps the {xdg_link} implementation which provides access to the following environment variables:
** `+$XDG_CACHE_HOME+`
** `+$XDG_CONFIG_HOME+`
** `+$XDG_CONFIG_DIRS+`
** `+$XDG_DATA_HOME+`
** `+$XDG_DATA_DIRS+`
** `+$XDG_STATE_HOME+`
* Enhances the {xdg_link} cache, config, data, and state implementations with dynamic global and local detection.

== Requirements

. https://www.ruby-lang.org[Ruby]

== Setup

To install _with_ security, run:

[source,bash]
----
# 💡 Skip this line if you already have the public certificate installed.
gem cert --add <(curl --compressed --location https://alchemists.io/gems.pem)
gem install runcom --trust-policy HighSecurity
----

To install _without_ security, run:

[source,bash]
----
gem install runcom
----

You can also add the gem directly to your project:

[source,bash]
----
bundle add runcom
----

Once the gem is installed, you only need to require it:

[source,ruby]
----
require "runcom"
----

== Usage

The following describes the enhancements built atop the {xdg_link} implementation.

=== Overview

While there isn’t a sole convenience object as found with the `XDG` gem, you can instantiate each object individually:

[source,ruby]
----
cache = Runcom::Cache.new "demo/data.json"
config = Runcom::Config.new "demo/configuration.yml"
data = Runcom::Data.new "demo/store.dat"
state = Runcom::State.new "demo/history.log"
----

By default, each Runcom object expects a relative file path but you can also use a fully qualified path when constructing a new instance.

Each of the above objects share the same Object API:

* `#initial`: Answers the initial path -- which can be a relative or absolute path -- from which the object was constructed.
* `#namespace`: Answers the namespace as a pathname object from which the instance was constructed. The namespace must be unique and identical across the cache, config, data, and state objects since this is what identifies and organizes all files associated with your program.
* `#file_name`: Answers the file name from which the object was constructed.
* `#active`: Answers first _existing file path_ as computed by `+$XDG_*_HOME+` followed by each computed `+$XDG_*_DIRS+` path in order defined. Otherwise, `nil` is answered back when no path exists.
* `#passive`: Answers first path as computed by `+$XDG_*_HOME+` followed by each computed `+$XDG_*_DIRS+` path in order defined which _may_ or _may not_ exist. This behaves like `#active`  but doesn't care if the path exists. Handy for situations where you'd like the active path but can  fallback to creating the global path if otherwise.
* `#global`: Answers the first _existing_ or _non-existing_ global path.
* `#local`: Answers the first _existing_ or _non-existing_ local path.
* `#all`: Answers all paths which is the combined `+$XDG_*_HOME+` and `+$XDG_*_DIRS+` values in order defined. These paths _may_ or _may not_ exist.
* `#to_s`: Answers an _explicit_ string cast for the current environment.
* `#to_str`: Answers an _implicit_ string cast for the current environment.
* `#inspect`: Answers object inspection complete with object type, object ID, and all environment variables.

=== Examples

The following are examples of what you will see when exploring the Runcom objects within an IRB console:

[source,ruby]
----
# Initialization

cache = XDG::Cache.new "demo/projects.json"
config = XDG::Config.new "demo/settings.yml"
data = XDG::Data.new "demo/vault.store"
state = XDG::State.new "demo/history.log"

# Paths

cache.initial     # "#"
cache.namespace   # "#"
cache.file_name   # "#"
cache.active      # nil
cache.passive     # "#"
cache.global      # "#"
cache.local       # "#"
cache.all         # ["#", "#"]

config.initial    # "#"
config.namespace  # "#"
config.file_name  # "#"
config.active     # nil
config.passive    # "#"
config.global     # "#"
config.local      # "#"
config.all        # ["#", "#", "#"]

data.initial      # "#"
data.namespace    # "#"
data.file_name    # "#"
data.active       # nil
data.passive      # "#"
data.global       # "#"
data.local        # "#"
data.all          # ["#", "#", "#", "#"]

state.initial     # "#"
state.namespace   # "#"
state.file_name   # "#"
state.active      # nil
state.passive     # "#"
state.global      # "#"
state.local       # "#"
state.all         # ["#", "#"]

# Casts (explicit and implicit)

cache.to_s        # "XDG_CACHE_HOME=/Users/demo/Engineering/OSS/runcom/.cache:/Users/demo/.cache"
config.to_s       # "XDG_CONFIG_HOME=/Users/demo/Engineering/OSS/runcom/.config:/Users/demo/.config XDG_CONFIG_DIRS=/etc/xdg"
data.to_s         # "XDG_DATA_HOME=/Users/demo/Engineering/OSS/runcom/.local/share:/Users/demo/.local/share XDG_DATA_DIRS=/usr/local/share:/usr/share"
state.to_s        # "XDG_STATE_HOME=/Users/demo/Engineering/OSS/runcom/.local/state:/Users/demo/.local/state"

cache.to_str      # "XDG_CACHE_HOME=/Users/demo/Engineering/OSS/runcom/.cache:/Users/demo/.cache"
config.to_str     # "XDG_CONFIG_HOME=/Users/demo/Engineering/OSS/runcom/.config:/Users/demo/.config XDG_CONFIG_DIRS=/etc/xdg"
data.to_str       # "XDG_DATA_HOME=/Users/demo/Engineering/OSS/runcom/.local/share:/Users/demo/.local/share XDG_DATA_DIRS=/usr/local/share:/usr/share"
state.to_str      # "XDG_STATE_HOME=/Users/demo/Engineering/OSS/runcom/.local/state:/Users/demo/.local/state"

# Inspection

cache.inspect     # "#"
config.inspect    # "#"
data.inspect      # "#"
state.inspect     # "#"
----

=== Variable Priority

Path precedence is determined in the following order (with the first taking highest priority):

. *Local Configuration*: If a `+$XDG_*_HOME+` or `+$XDG_*_DIRS+` path relative to the
  current working directory is detected, it will take precedence over the global configuration.
  This is the same behavior as found in Git where the local `.git/config` takes precedence over the
  global `$HOME/.gitconfig`.
. *Global Configuration*: When a local configuration isn’t found, the global configuration is used
  as defined by the _XDG Base Directory Specification_.

=== Building Blocks

While {xdg_link} and Runcom are powerful in their own right, a great building block you can add on top of this gem is the {etcher_link} gem which loads, transforms, validates, and produces structured data from raw Runcom information. For more sophisticated applications, this synergetic coupling of `XDG + Runcom + Etcher` makes for nicely designed architectures.

=== Examples

Examples of gems built atop this gem are:

* link:https://alchemists.io/projects/rubysmith[Rubysmith]: A command line interface for
  smithing Ruby projects.
* link:https://alchemists.io/projects/gemsmith[Gemsmith]: A command line interface for smithing
  new Ruby gems.
* link:https://alchemists.io/projects/hanamismith[Hanamismith]: A command line interface for smithing link:https://hanamirb.org[Hanami] projects.
* link:https://alchemists.io/projects/git-lint[Git Lint]: Enforces consistent Git commits.
* link:https://alchemists.io/projects/milestoner[Milestoner]: A command line interface for
  releasing Git repository milestones.
* link:https://alchemists.io/projects/pennyworth[Pennyworth]: A command line interface that
  enhances and extends link:https://www.alfredapp.com[Alfred] with Ruby support.
* link:https://alchemists.io/projects/pragmater[Pragmater]: A command line interface for
  managing/formatting source file pragma comments.
* link:https://alchemists.io/projects/sublime_text_kit[Sublime Text Kit]: A command line
  interface for managing Sublime Text metadata.
* link:https://alchemists.io/projects/tocer[Tocer]: A command line interface for generating
  Markdown table of contents.

== Development

To contribute, run:

[source,bash]
----
git clone https://github.com/bkuhlmann/runcom
cd runcom
bin/setup
----

You can also use the IRB console for direct access to all objects:

[source,bash]
----
bin/console
----

Lastly, there is a `bin/demo` script which displays default functionality for quick visual reference. This is the same script used to generate the usage examples shown at the top of this document.

[source,bash]
----
bin/demo
----

== Tests

To test, run:

[source,bash]
----
bin/rake
----

== link:https://alchemists.io/policies/license[License]

== link:https://alchemists.io/policies/security[Security]

== link:https://alchemists.io/policies/code_of_conduct[Code of Conduct]

== link:https://alchemists.io/policies/contributions[Contributions]

== link:https://alchemists.io/policies/developer_certificate_of_origin[Developer Certificate of Origin]

== link:https://alchemists.io/projects/runcom/versions[Versions]

== link:https://alchemists.io/community[Community]

== Credits

* Built with link:https://alchemists.io/projects/gemsmith[Gemsmith].
* Engineered by link:https://alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].

Owner

  • Name: Brooke Kuhlmann
  • Login: bkuhlmann
  • Kind: user
  • Location: Boulder, CO USA
  • Company: Alchemists

Quality over quantity.

Citation (CITATION.cff)

cff-version: 1.2.0
message: Please use the following metadata when citing this project in your work.
title: Runcom
abstract: A XDG enhanced run command manager for command line interfaces.
version: 12.3.0
license: Hippocratic-2.1
date-released: 2025-07-15
authors:
  - family-names: Kuhlmann
    given-names: Brooke
    affiliation: Alchemists
    orcid: https://orcid.org/0000-0002-5810-6268
keywords:
 - ruby
 - command line interface
 - XDG
 - base directory specification
 - cache
 - configuration
 - data
 - runtime
repository-code: https://github.com/bkuhlmann/runcom
repository-artifact: https://rubygems.org/gems/runcom
url: https://alchemists.io/projects/runcom

GitHub Events

Total
  • Watch event: 1
  • Delete event: 145
  • Push event: 32
  • Create event: 7
Last Year
  • Watch event: 1
  • Delete event: 145
  • Push event: 32
  • Create event: 7

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 570
  • Total Committers: 1
  • Avg Commits per committer: 570.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 56
  • Committers: 1
  • Avg Commits per committer: 56.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Brooke Kuhlmann b****e@a****o 570
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • rubygems 264,379 total
  • Total dependent packages: 16
    (may contain duplicates)
  • Total dependent repositories: 32
    (may contain duplicates)
  • Total versions: 93
  • Total maintainers: 1
proxy.golang.org: github.com/bkuhlmann/runcom
  • Versions: 14
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 6.5%
Average: 6.7%
Dependent repos count: 6.9%
Last synced: 4 months ago
rubygems.org: runcom

A XDG enhanced run command manager for command line interfaces.

  • Versions: 79
  • Dependent Packages: 16
  • Dependent Repositories: 32
  • Downloads: 264,379 Total
Rankings
Dependent packages count: 1.4%
Dependent repos count: 4.4%
Downloads: 5.9%
Average: 9.2%
Stargazers count: 12.4%
Forks count: 22.1%
Maintainers (1)
Funding
  • https://github.com/sponsors/bkuhlmann
Last synced: 4 months ago

Dependencies

Gemfile rubygems
  • amazing_print ~> 1.4 development
  • caliber ~> 0.11 development
  • debug ~> 1.6 development
  • git-lint ~> 4.0 development
  • guard-rspec ~> 4.7 development
  • rake ~> 13.0 development
  • reek ~> 6.1 development
  • rspec ~> 3.11 development
  • simplecov ~> 0.21 development
runcom.gemspec rubygems
  • refinements ~> 9.6
  • xdg ~> 6.6