From b48a2e2ea03935eefb7f9434c5c3008b4b02c85f Mon Sep 17 00:00:00 2001 From: EmilyGraceSeville7cf Date: Sun, 11 Feb 2024 01:39:49 +1000 Subject: [PATCH 1/3] feat: config schema --- schemas/schema.json | 61 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 schemas/schema.json diff --git a/schemas/schema.json b/schemas/schema.json new file mode 100644 index 0000000..18cc120 --- /dev/null +++ b/schemas/schema.json @@ -0,0 +1,61 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Cobra CLI settings", + "description": "Cobra CLI settings", + "type": "object", + "properties": { + "author": { + "title": "author", + "description": "An author of the project", + "type": "string", + "minLength": 1, + "examples": ["Steve Francia "] + }, + "license": { + "title": "license", + "description": "A license of the project", + "oneOf": [ + { + "type": "string", + "examples": [ + "GPLv2", + "GPLv3", + "LGPL", + "AGPL", + "MIT", + "2-Clause BSD", + "3-Clause BSD" + ] + }, + { + "type": "object", + "properties": { + "header": { + "title": "header", + "description": "A header of the license", + "type": "string", + "minLength": 1, + "examples": ["This file is part of CLI application foo."] + }, + "text": { + "title": "text", + "description": "A text of the license\nVariables:\n- copyright", + "type": "string", + "minLength": 1, + "examples": [ + "{{ .copyright }}\n\nThis is my license. There are many like it, but this one is mine.\nMy license is my best friend. It is my life. I must master it as I must\nmaster my life.\n" + ] + } + }, + "additionalProperties": false + } + ] + }, + "useViper": { + "title": "use Viper", + "description": "Whether to use Viper for managing project configuration", + "type": "boolean" + } + }, + "additionalProperties": false +} From 972ad0e9e2962cf0c16f0671cdded4441cd9b591 Mon Sep 17 00:00:00 2001 From: EmilyGraceSeville7cf Date: Sun, 11 Feb 2024 01:45:37 +1000 Subject: [PATCH 2/3] feat: require not empty strings --- schemas/schema.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/schemas/schema.json b/schemas/schema.json index 18cc120..3655d3b 100644 --- a/schemas/schema.json +++ b/schemas/schema.json @@ -9,6 +9,7 @@ "description": "An author of the project", "type": "string", "minLength": 1, + "pattern": "\\S", "examples": ["Steve Francia "] }, "license": { @@ -17,6 +18,8 @@ "oneOf": [ { "type": "string", + "minLength": 1, + "pattern": "\\S", "examples": [ "GPLv2", "GPLv3", @@ -35,6 +38,7 @@ "description": "A header of the license", "type": "string", "minLength": 1, + "pattern": "\\S", "examples": ["This file is part of CLI application foo."] }, "text": { @@ -42,6 +46,7 @@ "description": "A text of the license\nVariables:\n- copyright", "type": "string", "minLength": 1, + "pattern": "\\S", "examples": [ "{{ .copyright }}\n\nThis is my license. There are many like it, but this one is mine.\nMy license is my best friend. It is my life. I must master it as I must\nmaster my life.\n" ] From 43e4070ff47c7aa1fd600072406fecbb47846d6d Mon Sep 17 00:00:00 2001 From: EmilyGraceSeville7cf Date: Sun, 11 Feb 2024 01:47:40 +1000 Subject: [PATCH 3/3] feat: add urls --- schemas/schema.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/schemas/schema.json b/schemas/schema.json index 3655d3b..6e2eddd 100644 --- a/schemas/schema.json +++ b/schemas/schema.json @@ -6,7 +6,7 @@ "properties": { "author": { "title": "author", - "description": "An author of the project", + "description": "An author of the project\nhttps://github.com/spf13/cobra-cli", "type": "string", "minLength": 1, "pattern": "\\S", @@ -14,7 +14,7 @@ }, "license": { "title": "license", - "description": "A license of the project", + "description": "A license of the project\nhttps://github.com/spf13/cobra-cli", "oneOf": [ { "type": "string", @@ -35,7 +35,7 @@ "properties": { "header": { "title": "header", - "description": "A header of the license", + "description": "A header of the license\nhttps://github.com/spf13/cobra-cli", "type": "string", "minLength": 1, "pattern": "\\S", @@ -43,7 +43,7 @@ }, "text": { "title": "text", - "description": "A text of the license\nVariables:\n- copyright", + "description": "A text of the license\nVariables:\n- copyright\nhttps://github.com/spf13/cobra-cli", "type": "string", "minLength": 1, "pattern": "\\S", @@ -58,7 +58,7 @@ }, "useViper": { "title": "use Viper", - "description": "Whether to use Viper for managing project configuration", + "description": "Whether to use Viper (https://github.com/spf13/viper) for managing project configuration\nhttps://github.com/spf13/cobra-cli", "type": "boolean" } },