11 Commits
0.4.0 ... 0.4.2

Author SHA1 Message Date
a703dd375c fix docs and readme 2020-12-17 21:18:14 +03:00
2fbd9030eb Update README.md
Add CodeQL badge
2020-12-17 21:07:31 +03:00
75265509f3 Create codeql-analysis.yml 2020-12-17 20:59:36 +03:00
ab44e1c12d Update README.md 2020-12-11 16:16:14 +03:00
8d912597cf feat: add auto test (github actions) 2020-12-11 16:14:01 +03:00
60c08d2a2d Merge branch 'master' of https://github.com/GenZmeY/multini 2020-12-11 16:04:34 +03:00
67648811a5 fix: save the version when building manually 2020-12-11 15:57:24 +03:00
9cc9af1759 perf: remove debuginfo from release binary 2020-12-11 15:38:12 +03:00
96aa1540ab Update README.md 2020-11-09 21:29:47 +03:00
88d1ec4201 Update README.md 2020-11-09 21:07:26 +03:00
47b9dba690 Update README.MD 2020-11-09 20:35:21 +03:00
7 changed files with 172 additions and 9 deletions

View File

@ -23,7 +23,7 @@ jobs:
go-version: '1.13.0'
- name: Build
run: make -j $(nproc) compile VERSION=${{ steps.get_version.outputs.VERSION }}
run: make -j $(nproc) compile
- name: create release
id: create_release
@ -32,7 +32,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
release_name: Release ${{ steps.get_version.outputs.VERSION }}
release_name: multini ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false

34
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@ -0,0 +1,34 @@
name: "CodeQL"
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: '29 4 * * 2'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

23
.github/workflows/tests.yml vendored Normal file
View File

@ -0,0 +1,23 @@
name: tests
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.13.0'
- name: Build
run: make -j $(nproc) && make test

View File

@ -1,7 +1,7 @@
NAME = multini
VERSION = dev_$(shell date +%F_%T)
VERSION := $(shell git describe)
GOCMD = go
LDFLAGS := "$(LDFLAGS) -X 'main.Version=$(VERSION)'"
LDFLAGS := "$(LDFLAGS) -s -w -X 'main.Version=$(VERSION)'"
GOBUILD = $(GOCMD) build -ldflags=$(LDFLAGS)
SRCMAIN = ./cmd/$(NAME)
SRCDOC = ./doc

111
README.md
View File

@ -1,2 +1,109 @@
# multini
it's like crudini but for ini files with duplicate parameter names
# Multini
[![build](https://github.com/GenZmeY/multini/workflows/build/badge.svg)](https://github.com/GenZmeY/multini/actions?query=workflow%3Abuild)
[![tests](https://github.com/GenZmeY/multini/workflows/tests/badge.svg)](https://github.com/GenZmeY/multini/actions?query=workflow%3Atests)
[![CodeQL](https://github.com/GenZmeY/multini/workflows/CodeQL/badge.svg)](https://github.com/GenZmeY/multini/security/code-scanning)
[![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/GenZmeY/multini)](https://golang.org)
[![GitHub](https://img.shields.io/github/license/genzmey/multini)](LICENSE)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/GenZmeY/multini)](https://github.com/GenZmeY/multini/releases)
*Command line utility for manipulating ini files with duplicate key names.*
A compiled version of multini is available on the [release page](https://github.com/GenZmeY/multini/releases).
***
# Description
Some programs use ini file format with duplicate key names.
For example, these are games based on the [unreal engine](https://en.wikipedia.org/wiki/Unreal_Engine).
It might look like this (part of the Killing Floor 2 config):
```
[OnlineSubsystemSteamworks.KFWorkshopSteamworks]
ServerSubscribedWorkshopItems=2267561023
ServerSubscribedWorkshopItems=2085786712
ServerSubscribedWorkshopItems=2222630586
ServerSubscribedWorkshopItems=2146677560
```
Most implementations only support having one property with a given name in a section. If there are several of them, only the first (or last) key will be processed, which is not enough in this case. multini solves this problem.
**note:**
- multini is case sensitive;
- quotes around the value are not processed (they are part of the value for multini);
- multi-line values are not supported.
(but this may change in the future)
# Build & Install (Manual)
1. Install [golang](https://golang.org), [git](https://git-scm.com/), [make](https://www.gnu.org/software/make/);
2. Clone this repo: `git clone https://github.com/GenZmeY/multini`
3. Go to the source directory: `cd multini`
4. Build: `make`
5. Install: `make install`
# Usage
```
Usage: multini [OPTION]... ACTION ini_file [section] [key] [value]
Actions:
-g, --get Get values for a given combination of parameters.
-s, --set Set values for a given combination of parameters.
-a, --add Add values for a given combination of parameters.
-d, --del Delete the given combination of parameters.
-c, --chk Display parsing errors for the specified file.
Options:
-e, --existing For --set and --del, fail if item is missing.
-r, --reverse For --add, adds an item to the top of the section
-i, --inplace Lock and write files in place.
This is not atomic but has less restrictions
than the default replacement method.
-o, --output FILE Write output to FILE instead. '-' means stdout
-u, --unix Use LF as end of line
-w, --windows Use CRLF as end of line
-q, --quiet Suppress all normal output
-h, --help Write this help to stdout
--version Write version to stdout
```
# Examples
**output a global value not in a section:**
`multini --get ini_file '' key`
**output section:**
`multini --get ini_file section`
**output list of existing sections:**
`multini --get ini_file`
**output value:**
`multini --get ini_file section key`
- if there are several keys, a list of all values of this keys will be displayed
**create/update a single key:**
`multini --set ini_file section key value`
- if there is no key, it will be added
- if the key exists, the value will be updated
- if the key exists and has several values, the key with the specified value will be set, the rest of the values will be deleted
**add a key with specified value:**
`multini --add ini_file section key value`
- if there is no key, it will be added
- if the key exists and does not have the specified value, the new value will be added
- if the specified value repeats the existing one, no changes will be made
**delete all keys with specified name:**
`multini --del ini_file section key`
**delete a key with specified name and value:**
`multini --del ini_file section key value`
**delete a section:**
`multini --del ini_file section`
**short options can be combined:**
`multini -gq ini_file section key value`
- check the existence of a key with a given value using the return code
# License
Copyright © 2020 GenZmeY
The content of this repository is licensed under [MIT License](LICENSE).

View File

@ -40,7 +40,7 @@ var (
func printHelp() {
output.Println("A utility for manipulating ini files with duplicate keys")
output.Println("")
output.Println("Usage: multini [OPTION]... [ACTION] config_file [section] [param] [value]")
output.Println("Usage: multini [OPTION]... [ACTION] config_file [section] [key] [value]")
output.Println("Actions:")
output.Println(" -g, --get Get values for a given combination of parameters.")
output.Println(" -s, --set Set values for a given combination of parameters.")
@ -55,7 +55,6 @@ func printHelp() {
output.Println(" This is not atomic but has less restrictions")
output.Println(" than the default replacement method.")
output.Println(" -o, --output FILE Write output to FILE instead. '-' means stdout")
// output.Println(" -v, --verbose Indicate on stderr if changes were made")
output.Println(" -u, --unix Use LF as end of line")
output.Println(" -w, --windows Use CRLF as end of line")
output.Println(" -q, --quiet Suppress all normal output")

View File

@ -1,6 +1,6 @@
A utility for manipulating ini files with duplicate keys
Usage: multini [OPTION]... [ACTION] config_file [section] [param] [value]
Usage: multini [OPTION]... [ACTION] config_file [section] [key] [value]
Actions:
-g, --get Get values for a given combination of parameters.
-s, --set Set values for a given combination of parameters.