Skip to content

Commit 69f2b05

Browse files
authored
Merge pull request #64 from Jumpaku/fix/wrong-arguments-sort
fix: fixed a bug that arguments are wrongly sorted by name
2 parents f19320d + 609faa5 commit 69f2b05

19 files changed

Lines changed: 21 additions & 26 deletions

File tree

docs/cyamli-cli.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"$defs":{"Argument":{"description":"Argument represents a positional required argument in command line arguments.\n","properties":{"description":{"description":"Description of the argument.\nThe default value is an empty string.\n","type":"string"},"name":{"description":"Name of the argument, which must match the regular expression `^[a-z][a-z0-9]*$` and be unique in arguments of the command which the argument belongs to.\nThis property is required.\n","pattern":"^[a-z][a-z0-9]*(_[a-z0-9]+)*$","type":"string"},"type":{"$ref":"#/$defs/Type","description":"Type of the value that is assignable to the argument.\nThe default value is \"string\".\n"},"variadic":{"description":"Whether the argument is variadic (i.e. can have zero or more values).\nIt can be true only if this argument is the last argument in the arguments of the belonging command.\nThe default value is false.\n","type":"boolean"}},"required":["name"],"type":"object"},"Command":{"description":"Command represents a root command or a subcommand of the program.\nIt may have options, arguments, and subcommands recursively.\n","properties":{"arguments":{"description":"A list of arguments.\nThe default value is an empty array.\n","items":{"$ref":"#/$defs/Argument"},"type":"array"},"description":{"description":"Description of the command.\nThe default value is an empty string.\n","type":"string"},"options":{"additionalProperties":{"$ref":"#/$defs/Option"},"description":"A collection of options, which is a mapping from option names to options. \nThe default value is an empty object.\nA property name is a name of an option, which must match the regular expression `^(-[a-z][a-z0-9]*)+$` and be unique in options of the command.\n","propertyNames":{"pattern":"^(-[a-z][a-z0-9]*)+$"},"type":"object"},"subcommands":{"additionalProperties":{"$ref":"#/$defs/Command"},"description":"A collection of subcommands, which is a mapping from subcommand names to child commands.\nThe default value is an empty object.\nA property name is a name of a subcommand, which must match the regular expression `^[a-z][a-z0-9]*$` and be unique in subcommands of the command.\n","propertyNames":{"pattern":"^[a-z][a-z0-9]*$"},"type":"object"}},"type":"object"},"Option":{"description":"Option represents an optional argument in command line arguments.\n","properties":{"default":{"description":"String value representing the default value of the non-repeated option.\nIt must be a string that can be parsed as a value of the option type.\nIf not specified, the following values corresponding to the option type.\n- boolean (not repeated): \"false\"\n- string (not repeated): \"\"\n- integer (not repeated): \"0\"\n","type":"string"},"description":{"description":"Description of the option.\nThe default value is an empty string.\n","type":"string"},"negation":{"description":"Whether the option of typed boolean has a negated version.\nIf true then the option can be specified with a negation prefix `-no` in the command line arguments.\nThe default value is false.\n","type":"boolean"},"propagates":{"description":"Whether the option propagates to subcommands.\nIf true then the option is available in all subcommands of the command which the option belongs to.\nThe default value is false.\n","type":"boolean"},"repeated":{"description":"Whether the option can be specified multiple times.\nIf true then the option can be specified multiple times in the command line arguments.\nThe default value is false.\n","type":"boolean"},"short":{"description":"Short name of the option, which must match the regular expression `^-[a-z]$` and be unique in options of the command which the option belongs to.\nIf short is not specified then short name for this option is not available.\n","pattern":"(^$)|(^-[a-z]$)","type":"string"},"type":{"$ref":"#/$defs/Type","description":"Type of the value that is assignable to this option.\nThe default value is \"string\".\n"}},"type":"object"},"Program":{"allOf":[{"properties":{"name":{"description":"Name of the program.\nThe default value is an empty string.\n","type":"string"},"version":{"description":"Version of the program.\nThe default value is an empty string.\n","type":"string"}},"type":"object"},{"$ref":"#/$defs/Command"}],"description":"Program is a root command that may have a name and a version.\nIt consists of commands recursively.\n"},"Type":{"description":"Type represents a type of a value that can be assigned to an option or an argument.\nOne of \"string\", \"integer\", or \"boolean\" is available.\n","enum":["","string","integer","boolean"],"type":"string"}},"$id":"https://github.com/Jumpaku/cyamli/raw/v2.0.0-beta.2/docs/cyamli-cli.schema.json","$ref":"#/$defs/Program","$schema":"https://json-schema.org/draft/2020-12/schema","description":"CLI schema for cyamli.","title":"cyamli CLI schema"}
1+
{"$defs":{"Argument":{"description":"Argument represents a positional required argument in command line arguments.\n","properties":{"description":{"description":"Description of the argument.\nThe default value is an empty string.\n","type":"string"},"name":{"description":"Name of the argument, which must match the regular expression `^[a-z][a-z0-9]*$` and be unique in arguments of the command which the argument belongs to.\nThis property is required.\n","pattern":"^[a-z][a-z0-9]*(_[a-z0-9]+)*$","type":"string"},"type":{"$ref":"#/$defs/Type","description":"Type of the value that is assignable to the argument.\nThe default value is \"string\".\n"},"variadic":{"description":"Whether the argument is variadic (i.e. can have zero or more values).\nIt can be true only if this argument is the last argument in the arguments of the belonging command.\nThe default value is false.\n","type":"boolean"}},"required":["name"],"type":"object"},"Command":{"description":"Command represents a root command or a subcommand of the program.\nIt may have options, arguments, and subcommands recursively.\n","properties":{"arguments":{"description":"A list of arguments.\nThe default value is an empty array.\n","items":{"$ref":"#/$defs/Argument"},"type":"array"},"description":{"description":"Description of the command.\nThe default value is an empty string.\n","type":"string"},"options":{"additionalProperties":{"$ref":"#/$defs/Option"},"description":"A collection of options, which is a mapping from option names to options. \nThe default value is an empty object.\nA property name is a name of an option, which must match the regular expression `^(-[a-z][a-z0-9]*)+$` and be unique in options of the command.\n","propertyNames":{"pattern":"^(-[a-z][a-z0-9]*)+$"},"type":"object"},"subcommands":{"additionalProperties":{"$ref":"#/$defs/Command"},"description":"A collection of subcommands, which is a mapping from subcommand names to child commands.\nThe default value is an empty object.\nA property name is a name of a subcommand, which must match the regular expression `^[a-z][a-z0-9]*$` and be unique in subcommands of the command.\n","propertyNames":{"pattern":"^[a-z][a-z0-9]*$"},"type":"object"}},"type":"object"},"Option":{"description":"Option represents an optional argument in command line arguments.\n","properties":{"default":{"description":"String value representing the default value of the non-repeated option.\nIt must be a string that can be parsed as a value of the option type.\nIf not specified, the following values corresponding to the option type.\n- boolean (not repeated): \"false\"\n- string (not repeated): \"\"\n- integer (not repeated): \"0\"\n","type":"string"},"description":{"description":"Description of the option.\nThe default value is an empty string.\n","type":"string"},"negation":{"description":"Whether the option of typed boolean has a negated version.\nIf true then the option can be specified with a negation prefix `-no` in the command line arguments.\nThe default value is false.\n","type":"boolean"},"propagates":{"description":"Whether the option propagates to subcommands.\nIf true then the option is available in all subcommands of the command which the option belongs to.\nThe default value is false.\n","type":"boolean"},"repeated":{"description":"Whether the option can be specified multiple times.\nIf true then the option can be specified multiple times in the command line arguments.\nThe default value is false.\n","type":"boolean"},"short":{"description":"Short name of the option, which must match the regular expression `^-[a-z]$` and be unique in options of the command which the option belongs to.\nIf short is not specified then short name for this option is not available.\n","pattern":"(^$)|(^-[a-z]$)","type":"string"},"type":{"$ref":"#/$defs/Type","description":"Type of the value that is assignable to this option.\nThe default value is \"string\".\n"}},"type":"object"},"Program":{"allOf":[{"properties":{"name":{"description":"Name of the program.\nThe default value is an empty string.\n","type":"string"},"version":{"description":"Version of the program.\nThe default value is an empty string.\n","type":"string"}},"type":"object"},{"$ref":"#/$defs/Command"}],"description":"Program is a root command that may have a name and a version.\nIt consists of commands recursively.\n"},"Type":{"description":"Type represents a type of a value that can be assigned to an option or an argument.\nOne of \"string\", \"integer\", or \"boolean\" is available.\n","enum":["","string","integer","boolean"],"type":"string"}},"$id":"https://github.com/Jumpaku/cyamli/raw/v2.0.0/docs/cyamli-cli.schema.json","$ref":"#/$defs/Program","$schema":"https://json-schema.org/draft/2020-12/schema","description":"CLI schema for cyamli.","title":"cyamli CLI schema"}

docs/cyamli-cli.schema.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$schema: https://json-schema.org/draft/2020-12/schema
2-
$id: https://github.com/Jumpaku/cyamli/raw/v2.0.0-beta.2/docs/cyamli-cli.schema.json
2+
$id: https://github.com/Jumpaku/cyamli/raw/v2.0.0/docs/cyamli-cli.schema.json
33
title: cyamli CLI schema
44
description: CLI schema for cyamli.
55

docs/cyamli-docs.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<html lang="en">
22
<head>
33
<meta charset="UTF-8">
4-
<title>cyamli (v2.0.0-beta.2)</title>
4+
<title>cyamli (v2.0.0)</title>
55
</head>
66
<body>
77
<main>
8-
<h1>cyamli (v2.0.0-beta.2)</h1>
8+
<h1>cyamli (v2.0.0)</h1>
99

1010

1111
<section>

docs/cyamli-docs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# cyamli (v2.0.0-beta.2)
1+
# cyamli (v2.0.0)
22

33

44
## cyamli

docs/cyamli-docs.text

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cyamli (v2.0.0-beta.2)
1+
cyamli (v2.0.0)
22

33

44
cyamli

test/dart3/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ WORKDIR /workspace
44

55

66
RUN dart --disable-analytics
7-
COPY pubspec.yaml .
7+
8+
WORKDIR /workspace
9+
COPY . /workspace
810
RUN dart pub get
911

v2/cmd/cyamli/cli.cyamli.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: cyamli
2-
version: v2.0.0-beta.2
2+
version: v2.0.0
33
description: A command line tool to generate CLI for your app from YAML-based schema.
44
options:
55
-help:

v2/cmd/cyamli/cli.gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v2/generate/cpp/data.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ package cpp
22

33
import (
44
"fmt"
5+
"slices"
6+
"strconv"
7+
"strings"
8+
59
"github.com/Jumpaku/cyamli/v2/docs"
610
"github.com/Jumpaku/cyamli/v2/name"
711
"github.com/Jumpaku/cyamli/v2/schema"
812
"github.com/samber/lo"
9-
"slices"
10-
"strconv"
11-
"strings"
1213
)
1314

1415
type Data struct {
@@ -176,7 +177,6 @@ func ConstructData(s schema.Schema, headerFile, namespace, generatorName string)
176177
Variadic: argument.Variadic,
177178
})
178179
}
179-
slices.SortFunc(arguments, func(a, b ArgumentData) int { return a.Name.Cmp(b.Name) })
180180

181181
return CommandData{
182182
Program: s.Program.Name,

v2/generate/csharp/data.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ func ConstructData(s schema.Schema, namespace, generatorName string) Data {
193193
Variadic: argument.Variadic,
194194
})
195195
}
196-
slices.SortFunc(arguments, func(a, b ArgumentData) int { return a.Name.Cmp(b.Name) })
197196

198197
return CommandData{
199198
Program: s.Program.Name,

0 commit comments

Comments
 (0)