{"id":21619116,"url":"https://github.com/bannzai/userdefaultsgenerator","last_synced_at":"2025-04-11T08:43:32.095Z","repository":{"id":52809981,"uuid":"209073579","full_name":"bannzai/UserDefaultsGenerator","owner":"bannzai","description":"UserDefaultsGenerator generate swift code for easily management for (NS)UserDefaults key and value type.","archived":false,"fork":false,"pushed_at":"2021-04-18T15:44:20.000Z","size":70,"stargazers_count":30,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T05:00:03.067Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bannzai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-17T14:17:18.000Z","updated_at":"2022-05-08T06:31:52.000Z","dependencies_parsed_at":"2022-08-23T06:10:40.232Z","dependency_job_id":null,"html_url":"https://github.com/bannzai/UserDefaultsGenerator","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bannzai%2FUserDefaultsGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bannzai%2FUserDefaultsGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bannzai%2FUserDefaultsGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bannzai%2FUserDefaultsGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bannzai","download_url":"https://codeload.github.com/bannzai/UserDefaultsGenerator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248362583,"owners_count":21091162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T23:07:56.851Z","updated_at":"2025-04-11T08:43:32.056Z","avatar_url":"https://github.com/bannzai.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"## UserDefaultsGenerator\nUserDefaultsGenerator generate swift code for easily management for (NS)UserDefaults key and value type.\n\n## Usage\nFirst, you should prepare `udg.yml` file of below structure.\n\n```yml\n- name: numberOfIndent\n  type: Int\n\n- name: UserSelectedDarkMode\n  type: Bool\n  key: DarkMode\n\n- name: XYZ\n  type: Array\n```\n\nNext, and exec below command.\n```\n$ udg generate \n```\n\nLast, you can confirm result of udg command about generated swift code for managiment UserDefaults.\n```swift\npublic enum UDGArrayKey: String {\n  case XYZ\n}\npublic enum UDGBoolKey: String {\n  case UserSelectedDarkMode = \"DarkMode\"\n}\npublic enum UDGIntKey: String {\n  case numberOfIndent\n}\n\n// MARK: - UserDefaults Array Extension\nextension UserDefaults {\n  public func array(forKey key: UDGArrayKey) -\u003e [Any]? {\n    return array(forKey: key.rawValue)\n  }\n  public func set(_ value: [Any]?, forKey key: UDGArrayKey) {\n    set(value, forKey: key.rawValue)\n    synchronize()\n  }\n}\n// MARK: - Bool Extension\nextension UserDefaults {\n  public func bool(forKey key: UDGBoolKey) -\u003e Bool {\n    return bool(forKey: key.rawValue)\n  }\n  public func set(_ value: Bool, forKey key: UDGBoolKey) {\n    set(value, forKey: key.rawValue)\n    synchronize()\n  }\n}\n// MARK: - Int Extension\nextension UserDefaults {\n  public func integer(forKey key: UDGIntKey) -\u003e Int {\n    return integer(forKey: key.rawValue)\n  }\n  public func set(_ value: Int, forKey key: UDGIntKey) {\n    set(value, forKey: key.rawValue)\n    synchronize()\n  }\n}\n\n```\n\n### udg command option\n```shell\n$ udg --help\nUsage:\n  udg [command]\n\nAvailable Commands:\n  generate    generate [--output $OUTPUT_PATH] [--config $CONFIG_PATH] [--template $TEMPLATE_PATH]\n  setup       setup can be generated example config file\n  help        Help about any command\n```\n\n#### udg generate command option description\n|  Option  |  Description  |  \n| ---- | ---- |\n|  --output  |  Output path for generated swift code. Default is UserDefaultsGenerator.generated.swift |\n|  --config  |  Input configuration path of yml file. Default is ./udg.yml |\n|  --template  |  Using template path about swift code. Template format is stencil.  |\n\n\n\n\n## Yaml Configuration \n|  Key  |  Description  |  Required/Optional  |\n| ---- | ---- | ---- |\n|  name  |  Name of UserDefaults type key  |  Required  |\n|  type  |  Type of UserDefaults stored value  |  Required  |\n|  key  |  Custom key name if you want to use different name  |  Optional  |\n\n\n### Supported Swift Type\nEverything supported by Apple's UserDefaults is supported in a similar format.\nDocument: https://developer.apple.com/documentation/foundation/userdefaults\n\n|  SwiftType  |  Yaml configuration `type` name  |\n| ---- | ---- |\n| Any | Any |\n| URL | URL |\n| [Any]  | Array |\n| [String: Any] | Dictionary |\n| String | String |\n| [String] | StringArray |\n| Data | Data |\n| Bool | Bool |\n| Int | Int |\n| Float | Float |\n| Double | Double |\n\n[See also, SwiftType.swift](./Sources/UserDefaultsGeneratorCore/SwiftType.swift)\n\n## Install\nIt is recommended to use `mint`\n\n```shell\n$ mint install bannzai/UserDefaultsGenerator\n```\n\n## LICENSE\nUserDefaultsGenerator is available under the MIT license. See the LICENSE file for more info.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbannzai%2Fuserdefaultsgenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbannzai%2Fuserdefaultsgenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbannzai%2Fuserdefaultsgenerator/lists"}