8 releases

new 0.3.1 Nov 27, 2024
0.3.0 Nov 26, 2024
0.2.1 Sep 29, 2024
0.1.3 Sep 29, 2024

#99 in Procedural macros

Download history 314/week @ 2024-09-23 124/week @ 2024-09-30 9/week @ 2024-10-07 3/week @ 2024-10-14 316/week @ 2024-11-25

316 downloads per month

MIT license

530KB
19K SLoC

GitHub Languages

All GitHub's supported languages.


Install

To use this library in your project, you can install by running the following command:

cargo add github-languages

Usage

Accessing Individual Language Information

You can access information about a specific language directly using its struct:

use github_languages::{Rust, Python};

fn main() {
    let rust_info = Rust::info();
    println!("Rust color: {}", rust_info.color);

    let python_info = Python::info();
    println!("Python ace_mode: {}", python_info.ace_mode);
}

Dynamic Language Lookups

For dynamic lookups, use the LANGUAGES static variable:

use github_languages::LANGUAGES;

fn main() {
    // Lookup by name
    if let Some(rust_lang) = LANGUAGES.get_by_name("Rust") {
        println!("Rust color: {}", rust_lang.color);
    }
    
    // Lookup by file extension
    if let Some(py_lang) = LANGUAGES.get_by_extension(".py") {
        println!("Python ace_mode: {}", py_lang.ace_mode);
    }
    
    // Iterate over all languages
    for lang in LANGUAGES.all_languages() {
        println!("Language: {}, ID: {}", lang.name, lang.language_id);
    }
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License

Dependencies

~24–335KB