Skip to content

Commit 789c0c7

Browse files
Renamed package to figs and added concurrency support
1 parent daec52e commit 789c0c7

File tree

8 files changed

+688
-497
lines changed

8 files changed

+688
-497
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2023 Andrei Raven Merlescu
1+
Copyright 2025 Andrei Raven Merlescu
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44

README.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
# Configurable Package
1+
# Figs
22

33
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
44

5-
The Configurable package provides a simple and flexible way to handle configuration data in your Go projects. It allows you to define and manage various types of configuration variables, such as integers, strings, booleans, durations, and more. This package supports configuration parsing from JSON, YAML, and INI files, as well as environment variables.
5+
The Configurable (`figs` as `cfigs`) package provides a simple and flexible way to handle configuration data in your Go projects. It allows you to define and manage various types of configuration variables, such as integers, strings, booleans, durations, and more. This package supports configuration parsing from JSON, YAML, and INI files, as well as environment variables.
66

77
## Installation
88

99
To use the Configurable package in your project, you need to have Go installed and set up. Then, you can install the package by running the following command in your terminal:
1010

1111
```shell
12-
go get -u github.com/andreimerlescu/configurable
12+
go get -u github.com/andreimerlescu/figs
1313
```
1414

1515
## Usage
1616

17-
To use the Configurable package in your Go code, you need to import it:
17+
To use **figs** package in your Go code, you need to import it:
1818

1919
```go
20-
import "github.com/andreimerlescu/configurable"
20+
import "github.com/andreimerlescu/figs"
2121
```
2222

2323
### Creating a Configurable Instance
2424

2525
To get started, you need to create an instance of the Configurable struct by calling the `NewConfigurable()` function:
2626

2727
```go
28-
config := configurable.New()
28+
cfigs := figs.New()
2929
```
3030

3131
### Defining Configuration Variables
3232

3333
The Configurable package provides several methods to define different types of configuration variables. Each method takes a name, default value, and usage description as parameters and returns a pointer to the respective variable:
3434

3535
```go
36-
port := config.NewInt("port", 8080, "The port number to listen on")
37-
timeout := config.NewDuration("timeout", time.Second * 5, "The timeout duration for requests")
38-
debug := config.NewBool("debug", false, "Enable debug mode")
36+
port := cfigs.NewInt("port", 8080, "The port number to listen on")
37+
timeout := cfigs.NewDuration("timeout", time.Second * 5, "The timeout duration for requests")
38+
debug := cfigs.NewBool("debug", false, "Enable debug mode")
3939
```
4040

4141
### Loading Configuration from Files
4242

4343
You can load configuration data from JSON, YAML, and INI files using the `LoadFile()` method:
4444

4545
```go
46-
err := config.LoadFile("config.json")
46+
err := cfigs.ParseFile("config.json")
4747
if err != nil {
4848
// Handle error
4949
}
@@ -56,10 +56,13 @@ The package automatically parses the file based on its extension. Make sure to p
5656
The Configurable package also allows you to parse command-line arguments. Call the `Parse()` method to parse the arguments after defining your configuration variables:
5757

5858
```go
59-
err := config.Parse("")
60-
if err != nil {
61-
// Handle error
62-
}
59+
cfigs.Parse()
60+
```
61+
62+
or
63+
64+
```go
65+
cfigs.Load()
6366
```
6467

6568
Passing an empty string to `Parse()` means it will only parse the command-line arguments and not load any file.
@@ -69,9 +72,9 @@ Passing an empty string to `Parse()` means it will only parse the command-line a
6972
You can access the values of your configuration variables using the respective getter methods:
7073

7174
```go
72-
fmt.Println("Port:", *port)
73-
fmt.Println("Timeout:", *timeout)
74-
fmt.Println("Debug mode:", *debug)
75+
fmt.Println("Port:", *cfigs.Int("port"))
76+
fmt.Println("Timeout:", *cfigs.Duration("timeout"))
77+
fmt.Println("Debug mode:", *cfigs.String("debug"))
7578
```
7679

7780
### Environment Variables
@@ -83,8 +86,7 @@ The Configurable package supports setting configuration values through environme
8386
To generate a usage string with information about your configuration variables, use the `Usage()` method:
8487

8588
```go
86-
usage := config.Usage()
87-
fmt.Println(usage)
89+
fmt.Println(cfigs.Usage())
8890
```
8991

9092
The generated usage string includes information about each configuration variable, including its name, default value, description, and the source from which it was set (flag, environment, JSON, YAML, or INI).
@@ -97,4 +99,4 @@ This package is distributed under the MIT License. See the [LICENSE](LICENSE) fi
9799

98100
Contributions to this package are welcome. If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
99101

100-
Enjoy using the Configurable package in your projects!
102+
Enjoy using the Figs package in your projects!

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

0 commit comments

Comments
 (0)