Coder Social home page Coder Social logo

etcetera's Introduction

crates.io version crates.io revdeps documentation license

Etcetera

This is a Rust library that allows you to determine the locations of configuration, data, cache & other files for your application. Existing Rust libraries generally do not give you a choice in terms of which standards/conventions they follow. Etcetera, on the other hand, gives you the choice.

MSRV: 1.54.0

Conventions

Etcetera supports the following conventions:

Strategies

Etcetera has 2 modes of operation: BaseStrategy & AppStrategy:

  • With BaseStrategy, you just get the location of the respective directory. For eg. for config_dir():
    • XDG: ~/.config
    • Apple: ~/Library/Preferences
    • Windows: ~\AppData\Roaming
  • With AppStrategy, you provide additional information to get the location of your app directory. For eg. if you provide the following details: { top_level_domain: "org", author: "Acme Corp", app_name: "Frobnicator Plus" }, you'll get:
    • XDG: ~/.config/frobnicator-plus
    • Unix: ~/.frobnicator-plus
    • Apple: ~/Library/Preferences/org.acmecorp.FrobnicatorPlus
    • Windows: ~\AppData\Roaming\Acme Corp\Frobnicator Plus

Note: the location of the home (~) is determined by the home crate.

Convenience functions

Etcetera also provides convenience functions for selecting the appropriate strategy on each platform:

  • base_strategy::choose_base_strategy & app_strategy::choose_app_strategy: Uses Windows on Windows & XDG everywhere else. This is used by most CLI tools & some GUI tools on each platform.
  • base_strategy::choose_native_strategy & app_strategy::choose_native_strategy: Uses Windows on Windows, Apple on macOS/iOS, & XDG everywhere else. This is used by most GUI applications on each platform.

See the documentation for examples.

etcetera's People

Contributors

lunacookies avatar mmatous avatar utkarshgupta137 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

etcetera's Issues

On windows use XDG base directory if set

On windows, I set XDG directories and I want to use this location instead of ~\AppData\Roaming. My home directory is full and I can't change it so I set my XDG directories to a different drive that I clone from git and update from git. Can you add a strategy to use XDG directories if set?

Allow arbitrary bundle_id

Hi there! Would it be possible to set the bundle_id directly, so as to not force the ‘com.foo.Bar’ format?
I’m happy to provide a PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.