docs: add the missing docs to get 100%

pull/4/head
Dominique Merle 3 years ago
parent 95640a5808
commit cbb5afadf2

@ -1,5 +1,13 @@
# Majority Judgment CLI tool
[![MIT](https://img.shields.io/github/license/MieuxVoter/majority-judgment-cli?style=for-the-badge)](LICENSE)
[![Release](https://img.shields.io/github/v/release/MieuxVoter/majority-judgment-cli?include_prereleases&style=for-the-badge)](https://github.com/MieuxVoter/majority-judgment-cli/releases)
[![Build Status](https://img.shields.io/github/workflow/status/MieuxVoter/majority-judgment-cli/Go?style=for-the-badge)](https://github.com/MieuxVoter/majority-judgment-cli/actions/workflows/go.yml)
[![Code Quality](https://img.shields.io/codefactor/grade/github/MieuxVoter/majority-judgment-cli?style=for-the-badge)](https://www.codefactor.io/repository/github/mieuxvoter/majority-judgment-cli)
[![A+](https://img.shields.io/badge/go%20report-A+-brightgreen.svg?style=for-the-badge)](https://goreportcard.com/report/github.com/mieuxvoter/majority-judgment-cli)
![LoC](https://img.shields.io/tokei/lines/github/MieuxVoter/majority-judgment-cli?style=for-the-badge)
[![Discord Chat](https://img.shields.io/discord/705322981102190593.svg?style=for-the-badge)](https://discord.gg/rAAQG9S)
> **WORK IN PROGRESS**
> Although the core mechanics are here and ranking does work,
> the features described in this README are not all implemented.

@ -8,8 +8,10 @@ import (
"strconv"
)
// CsvFormatter formats the results as CSV, with , as delimiter and " as quote
type CsvFormatter struct{}
// Format the provided results
func (t *CsvFormatter) Format(
pollTally *judgment.PollTally,
result *judgment.PollResult,

@ -2,12 +2,17 @@ package formatter
import "github.com/mieuxvoter/majority-judgment-library-go/judgment"
// Options are shared between all formatters.
// Some formatters may ignore some options.
type Options struct {
Sorted bool
Width int
}
// Formatter to implement to make another formatter
// Keep in mind you need to add it to the "if else if" in root command as well
type Formatter interface {
// Format the provided results
Format(
pollTally *judgment.PollTally,
result *judgment.PollResult,

@ -5,8 +5,11 @@ import (
"github.com/mieuxvoter/majority-judgment-library-go/judgment"
)
// JsonFormatter formats the output as … JSON
// All on one line, feel free to make an option if you can figure out how to beautify it
type JsonFormatter struct{}
// Format the provided results
func (t *JsonFormatter) Format(
tally *judgment.PollTally,
result *judgment.PollResult,

@ -8,8 +8,13 @@ import (
"strings"
)
// TextFormatter is the default formatter.
// It displays the proposals with their merit profiles and ranks.
// It does not use color (yet). ANSI colors are appalling.
// Perhaps we can use xterm colors?
type TextFormatter struct{}
// Format the provided results
func (t *TextFormatter) Format(
pollTally *judgment.PollTally,
result *judgment.PollResult,
@ -50,8 +55,7 @@ func (t *TextFormatter) Format(
}
for _, proposalResult := range proposalsResults {
line := ""
line += fmt.Sprintf(
line := fmt.Sprintf(
"#%0"+strconv.Itoa(amountOfDigitsForRank)+"d ",
proposalResult.Rank,
)

@ -15,7 +15,7 @@ func (t *YamlFormatter) Format(
options *Options,
) (string, error) {
// JSON can ignore options.Sorted because it always sends back everything
// Can ignore options.Sorted because it always sends back everything
jsonBytes, jsonErr := yaml.Marshal(struct {
Proposals []string `json:"proposals"`

Loading…
Cancel
Save