Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 33 additions & 39 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,38 @@
{
"name": "swift-argument-encoding",
"image": "swift:5.7",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "false",
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": "false"
},
"ghcr.io/devcontainers/features/git:1": {
"version": "os-provided",
"ppa": "false"
}
"name": "swift-argument-encoding",
"image": "swift:5.8",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "false",
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"upgradePackages": "false"
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"lldb.library": "/usr/lib/liblldb.so"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"sswg.swift-lang"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
"ghcr.io/devcontainers/features/git:1": {
"version": "os-provided",
"ppa": "false"
}
},
"runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"lldb.library": "/usr/lib/liblldb.so"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": ["swiftlang.swift-vscode"]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "swift --version",
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "swift --version",

// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
16 changes: 6 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,30 @@ on:

jobs:
lint:
runs-on: macos-13
runs-on: macos-latest
environment: default
steps:
- uses: actions/checkout@v4
- name: SwiftFormat version
run: swiftformat --version
- name: Format lint
run: swiftformat --lint .
- name: Install SwiftLint
run: brew install swiftlint
- name: SwiftLint version
run: swiftlint --version
- name: Lint
run: swiftlint lint --quiet
macos-test:
runs-on: macos-13
runs-on: macos-latest
environment: default
strategy:
matrix:
xcode: ["14.3", "15.0"]
# Swift: 5.8 , 5.9
steps:
- uses: actions/checkout@v4
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: Run Tests
run: swift test --enable-code-coverage --parallel
- name: Swift Coverage Report
run: xcrun llvm-cov export -format="lcov" .build/debug/swift-argument-encodingPackageTests.xctest/Contents/MacOS/swift-argument-encodingPackageTests -instr-profile .build/debug/codecov/default.profdata > coverage_report.lcov
- uses: codecov/codecov-action@v4
- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true # optional (default = false)
Expand All @@ -47,6 +43,6 @@ jobs:
environment: default

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run Tests
run: swift test --parallel
4 changes: 2 additions & 2 deletions .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
--redundanttype explicit
--swiftversion 5.8
--maxwidth 120
--header "{file}\nArgumentEncoding\n\nCopyright © {year} MFB Technologies, Inc. All rights reserved.\n\nThis source code is licensed under the MIT license found in the\nLICENSE file in the root directory of this source tree."
--header "{file}\nArgumentEncoding\n\nThis source code is licensed under the MIT License (MIT) found in the\nLICENSE file in the root directory of this source tree."
--allman false
--exclude **/output/**/*,.tuist-bin,**/.swiftpm/*,**/.build/*
--wraparguments before-first
--wrapcollections before-first
--wrapcollections before-first
4 changes: 1 addition & 3 deletions Examples/Sources/SwiftCommand/RunCommand.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// RunCommand.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import ArgumentEncoding
Expand Down
4 changes: 1 addition & 3 deletions Examples/Sources/SwiftCommand/SwiftCommand.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// SwiftCommand.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import ArgumentEncoding
Expand Down
4 changes: 1 addition & 3 deletions Examples/Sources/SwiftCommand/TestCommand.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// TestCommand.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import ArgumentEncoding
Expand Down
4 changes: 1 addition & 3 deletions Examples/Sources/SwiftCommand/main.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// main.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

let test = SwiftCommand.test(TestCommand(
Expand Down
4 changes: 1 addition & 3 deletions Sources/ArgumentEncoding/ArgumentGroup.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// ArgumentGroup.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import Dependencies
Expand Down
4 changes: 1 addition & 3 deletions Sources/ArgumentEncoding/CaseConverter.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// CaseConverter.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import Foundation
Expand Down
4 changes: 1 addition & 3 deletions Sources/ArgumentEncoding/Command.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Command.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

/// A command type argument with no nested or children arguments.
Expand Down
4 changes: 1 addition & 3 deletions Sources/ArgumentEncoding/CommandRepresentable.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// CommandRepresentable.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import Dependencies
Expand Down
4 changes: 1 addition & 3 deletions Sources/ArgumentEncoding/DecoderUserInfo+OptionHelpers.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// DecoderUserInfo+OptionHelpers.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// DecoderUserInfo+OptionSetHelpers.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import Foundation
Expand Down
4 changes: 1 addition & 3 deletions Sources/ArgumentEncoding/Flag.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Flag.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import Dependencies
Expand Down
4 changes: 1 addition & 3 deletions Sources/ArgumentEncoding/FormatterNode.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// FormatterNode.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

/// A protocol that describes a type that defines how flags and options are formatted. Typically, `ArgumentGroup`
Expand Down
4 changes: 1 addition & 3 deletions Sources/ArgumentEncoding/Formatters.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Formatters.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import Dependencies
Expand Down
4 changes: 1 addition & 3 deletions Sources/ArgumentEncoding/Option.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Option.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import Dependencies
Expand Down
4 changes: 1 addition & 3 deletions Sources/ArgumentEncoding/OptionSet.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// OptionSet.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import Dependencies
Expand Down
4 changes: 1 addition & 3 deletions Sources/ArgumentEncoding/PositionalArgument.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// PositionalArgument.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import Foundation
Expand Down
4 changes: 1 addition & 3 deletions Sources/ArgumentEncoding/StaticString+Constants.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// StaticString+Constants.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

extension StaticString {
Expand Down
4 changes: 1 addition & 3 deletions Sources/ArgumentEncoding/TopLevelCommandRepresentable.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// TopLevelCommandRepresentable.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

/// A type that represents a command type argument that is not a child of an `ArgumentGroup`.
Expand Down
34 changes: 9 additions & 25 deletions Tests/ArgumentEncodingTests/ArgumentGroupTests.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// ArgumentGroupTests.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import ArgumentEncoding
Expand Down Expand Up @@ -250,28 +248,14 @@ final class ArgumentGroupTests: XCTestCase {
}
}

#if swift(>=6)
extension Array: @retroactive ArgumentGroup, @retroactive FormatterNode {
public var flagFormatter: ArgumentEncoding.FlagFormatter { FlagFormatter(prefix: .doubleDash) }

public var optionFormatter: ArgumentEncoding.OptionFormatter { OptionFormatter(prefix: .doubleDash) }
}

extension Dictionary: @retroactive ArgumentGroup, @retroactive FormatterNode {
public var flagFormatter: ArgumentEncoding.FlagFormatter { FlagFormatter(prefix: .doubleDash) }

public var optionFormatter: ArgumentEncoding.OptionFormatter { OptionFormatter(prefix: .doubleDash) }
}
#else
extension Array: ArgumentGroup, FormatterNode {
public var flagFormatter: ArgumentEncoding.FlagFormatter { FlagFormatter(prefix: .doubleDash) }
extension Array: ArgumentGroup, FormatterNode {
public var flagFormatter: ArgumentEncoding.FlagFormatter { FlagFormatter(prefix: .doubleDash) }

public var optionFormatter: ArgumentEncoding.OptionFormatter { OptionFormatter(prefix: .doubleDash) }
}
public var optionFormatter: ArgumentEncoding.OptionFormatter { OptionFormatter(prefix: .doubleDash) }
}

extension Dictionary: ArgumentGroup, FormatterNode {
public var flagFormatter: ArgumentEncoding.FlagFormatter { FlagFormatter(prefix: .doubleDash) }
extension Dictionary: ArgumentGroup, FormatterNode {
public var flagFormatter: ArgumentEncoding.FlagFormatter { FlagFormatter(prefix: .doubleDash) }

public var optionFormatter: ArgumentEncoding.OptionFormatter { OptionFormatter(prefix: .doubleDash) }
}
#endif
public var optionFormatter: ArgumentEncoding.OptionFormatter { OptionFormatter(prefix: .doubleDash) }
}
4 changes: 1 addition & 3 deletions Tests/ArgumentEncodingTests/CommandRepresentableTests.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// CommandRepresentableTests.swift
// ArgumentEncoding
//
// Copyright © 2024 MFB Technologies, Inc. All rights reserved.
//
// This source code is licensed under the MIT license found in the
// This source code is licensed under the MIT License (MIT) found in the
// LICENSE file in the root directory of this source tree.

import ArgumentEncoding
Expand Down
Loading