-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e49b71
commit cf9f65b
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
### Go-UnFlagger | ||
|
||
The main purpose of this project is to remove feature flags in code wherever present by just running a single command. | ||
|
||
Currently this supports removal of flags by two conditions: | ||
|
||
##### 1. Removing Flag by name: | ||
|
||
While running the command if the flag's name is provided, it checks entire file to identify where a flag by this name is present and remove the block | ||
|
||
##### 2. Removing Flag's that are past the feature launch date: | ||
|
||
This case each feature flag is written with a separator(__) in the name and when flagger type is chosen as date it'll parse through all flags and check if it's date is less than current date and remove those. | ||
|
||
Currently existence of flag is determined by checking if there is an `if` statement with condition similar to `<some_package>.FeatureFlags.<flag_name>`. We can make this flexible by taking the condition regex as command-line argument. | ||
|
||
For this project to work with your code base use a struct with feature flags as the attributes. | ||
|
||
### Usage: | ||
|
||
Usage of bin/flagger: | ||
|
||
Download the latest release from [https://github.com/Prashant-Surya/go-unflagger/releases](https://github.com/Prashant-Surya/go-unflagger/releases) and place it in a folder available in `$PATH` | ||
|
||
``` | ||
-date-format string | ||
Format of the date embedded in flag (default "2006_01_02" -> "yyyy_mm_dd") | ||
-name string | ||
Name of the flag to be removed | ||
-path string | ||
Relative or Absolute Path of the file or directory | ||
-recursive | ||
Recursively parse flags. (Enable in case -path is a directory) | ||
-type string | ||
Flagger Type. Possible values date, name (default "date") | ||
-write | ||
Enable this flag to update contents to file or it'll be written to stdout | ||
``` | ||
|
||
##### Examples: | ||
|
||
1. Removing a feature flag with name `launch_v1` from a directory at `/Users/surya/go/src/testProject`. | ||
``` | ||
flagger -path /Users/surya/go/src/testProject -recursive -type name -name launch_v1 | ||
``` | ||
|
||
2. Removing a feature flag with name `launch_v1` from a file at `/Users/surya/go/src/testProject/main.go`. | ||
``` | ||
flagger -path /Users/surya/go/src/testProject/main.go -type name -name launch_v1 | ||
``` | ||
|
||
3. Removing multiple feature flags with name `launch_v1__2019_04_04`, `launch_v2__2019_05_04` from a file at `/Users/surya/go/src/testProject/main.go` using date type flagger. | ||
``` | ||
flagger -path /Users/surya/go/src/testProject/main.go -type date | ||
``` |