@@ -30,6 +30,18 @@ struct ComposeCommand: AsyncParsableCommand {
3030 ComposeUnpause . self,
3131 ComposeLs . self,
3232 ComposeCp . self,
33+ ComposeEvents . self,
34+ ComposeAttach . self,
35+ ComposeCommit . self,
36+ ComposeExport . self,
37+ ComposeScale . self,
38+ ComposeStats . self,
39+ ComposeVersion . self,
40+ ComposeVolumes . self,
41+ ComposeWait . self,
42+ ComposeWatch . self,
43+ ComposeBridge . self,
44+ ComposePublish . self,
3345 ]
3446 )
3547}
@@ -1519,3 +1531,351 @@ struct ComposeCp: AsyncParsableCommand {
15191531 }
15201532 }
15211533}
1534+
1535+ // MARK: - Compose Events
1536+
1537+ struct ComposeEvents : AsyncParsableCommand {
1538+ static let configuration = CommandConfiguration (
1539+ commandName: " events " ,
1540+ abstract: " Receive real time events from containers "
1541+ )
1542+
1543+ @OptionGroup var options : ComposeOptions
1544+
1545+ @Flag ( name: . customLong( " dry-run " ) , help: " Execute command in dry run mode " )
1546+ var dryRun = false
1547+
1548+ @Flag ( name: . long, help: " Output events as a stream of json objects " )
1549+ var json = false
1550+
1551+ @Option ( name: . long, help: " Show all events created since timestamp " )
1552+ var since : String ?
1553+
1554+ @Option ( name: . long, help: " Stream events until this timestamp " )
1555+ var until : String ?
1556+
1557+ @Argument ( help: " Service names " )
1558+ var services : [ String ] = [ ]
1559+
1560+ func run( ) async throws {
1561+ throw MockerError . operationFailed ( " compose events is not yet supported with Apple Containerization " )
1562+ }
1563+ }
1564+
1565+ // MARK: - Compose Attach
1566+
1567+ struct ComposeAttach : AsyncParsableCommand {
1568+ static let configuration = CommandConfiguration (
1569+ commandName: " attach " ,
1570+ abstract: " Attach local standard input, output, and error streams to a service's running container "
1571+ )
1572+
1573+ @OptionGroup var options : ComposeOptions
1574+
1575+ @Option ( name: . customLong( " detach-keys " ) , help: " Override the key sequence for detaching from a container " )
1576+ var detachKeys : String ?
1577+
1578+ @Flag ( name: . customLong( " dry-run " ) , help: " Execute command in dry run mode " )
1579+ var dryRun = false
1580+
1581+ @Option ( name: . long, help: " Index of the container if service has multiple replicas " )
1582+ var index : Int ?
1583+
1584+ @Flag ( name: . customLong( " no-stdin " ) , help: " Do not attach STDIN " )
1585+ var noStdin = false
1586+
1587+ @Flag ( name: . customLong( " sig-proxy " ) , help: " Proxy all received signals to the process " )
1588+ var sigProxy = false
1589+
1590+ @Argument ( help: " Service name " )
1591+ var service : String
1592+
1593+ func run( ) async throws {
1594+ let ( _, project) = try options. loadCompose ( )
1595+ let config = MockerConfig ( )
1596+ let engine = try ContainerEngine ( config: config)
1597+ let idx = index ?? 1
1598+ let containerName = " \( project) - \( service) - \( idx) "
1599+ try await engine. exec ( containerName, command: [ ] )
1600+ }
1601+ }
1602+
1603+ // MARK: - Compose Commit
1604+
1605+ struct ComposeCommit : AsyncParsableCommand {
1606+ static let configuration = CommandConfiguration (
1607+ commandName: " commit " ,
1608+ abstract: " Create a new image from a service container's changes "
1609+ )
1610+
1611+ @OptionGroup var options : ComposeOptions
1612+
1613+ @Option ( name: [ . customShort( " a " ) , . long] , help: " Author (e.g., \" John Hannibal Smith <hannibal@a-team.com> \" ) " )
1614+ var author : String ?
1615+
1616+ @Option ( name: [ . customShort( " c " ) , . long] , parsing: . singleValue, help: " Apply Dockerfile instruction to the created image " )
1617+ var change : [ String ] = [ ]
1618+
1619+ @Flag ( name: . customLong( " dry-run " ) , help: " Execute command in dry run mode " )
1620+ var dryRun = false
1621+
1622+ @Option ( name: . long, help: " Index of the container if service has multiple replicas " )
1623+ var index : Int ?
1624+
1625+ @Option ( name: [ . customShort( " m " ) , . long] , help: " Commit message " )
1626+ var message : String ?
1627+
1628+ @Flag ( name: . long, help: " Pause container during commit " )
1629+ var pause = false
1630+
1631+ @Argument ( help: " Service name " )
1632+ var service : String
1633+
1634+ @Argument ( help: " Repository[:tag] " )
1635+ var repository : String ?
1636+
1637+ func run( ) async throws {
1638+ throw MockerError . operationFailed ( " compose commit is not yet supported with Apple Containerization " )
1639+ }
1640+ }
1641+
1642+ // MARK: - Compose Export
1643+
1644+ struct ComposeExport : AsyncParsableCommand {
1645+ static let configuration = CommandConfiguration (
1646+ commandName: " export " ,
1647+ abstract: " Export a service container's filesystem as a tar archive "
1648+ )
1649+
1650+ @OptionGroup var options : ComposeOptions
1651+
1652+ @Flag ( name: . customLong( " dry-run " ) , help: " Execute command in dry run mode " )
1653+ var dryRun = false
1654+
1655+ @Option ( name: . long, help: " Index of the container if service has multiple replicas " )
1656+ var index : Int ?
1657+
1658+ @Option ( name: [ . customShort( " o " ) , . long] , help: " Write to a file, instead of STDOUT " )
1659+ var output : String ?
1660+
1661+ @Argument ( help: " Service name " )
1662+ var service : String
1663+
1664+ func run( ) async throws {
1665+ throw MockerError . operationFailed ( " compose export is not yet supported with Apple Containerization " )
1666+ }
1667+ }
1668+
1669+ // MARK: - Compose Scale
1670+
1671+ struct ComposeScale : AsyncParsableCommand {
1672+ static let configuration = CommandConfiguration (
1673+ commandName: " scale " ,
1674+ abstract: " Scale services "
1675+ )
1676+
1677+ @OptionGroup var options : ComposeOptions
1678+
1679+ @Flag ( name: . customLong( " dry-run " ) , help: " Execute command in dry run mode " )
1680+ var dryRun = false
1681+
1682+ @Flag ( name: . customLong( " no-deps " ) , help: " Don't start linked services " )
1683+ var noDeps = false
1684+
1685+ @Argument ( help: " Service=num pairs (e.g. web=3) " )
1686+ var scales : [ String ] = [ ]
1687+
1688+ func run( ) async throws {
1689+ throw MockerError . operationFailed ( " compose scale is not yet supported with Apple Containerization " )
1690+ }
1691+ }
1692+
1693+ // MARK: - Compose Stats
1694+
1695+ struct ComposeStats : AsyncParsableCommand {
1696+ static let configuration = CommandConfiguration (
1697+ commandName: " stats " ,
1698+ abstract: " Display a live stream of container(s) resource usage statistics "
1699+ )
1700+
1701+ @OptionGroup var options : ComposeOptions
1702+
1703+ @Flag ( name: . shortAndLong, help: " Show all containers (default shows just running) " )
1704+ var all = false
1705+
1706+ @Flag ( name: . customLong( " dry-run " ) , help: " Execute command in dry run mode " )
1707+ var dryRun = false
1708+
1709+ @Option ( name: . long, help: " Format output using a custom template " )
1710+ var format : String ?
1711+
1712+ @Flag ( name: . customLong( " no-stream " ) , help: " Disable streaming stats and only pull the first result " )
1713+ var noStream = false
1714+
1715+ @Flag ( name: . customLong( " no-trunc " ) , help: " Do not truncate output " )
1716+ var noTrunc = false
1717+
1718+ @Argument ( help: " Service names " )
1719+ var services : [ String ] = [ ]
1720+
1721+ func run( ) async throws {
1722+ throw MockerError . operationFailed ( " compose stats is not yet supported with Apple Containerization " )
1723+ }
1724+ }
1725+
1726+ // MARK: - Compose Version
1727+
1728+ struct ComposeVersion : AsyncParsableCommand {
1729+ static let configuration = CommandConfiguration (
1730+ commandName: " version " ,
1731+ abstract: " Show the Docker Compose version information "
1732+ )
1733+
1734+ @Flag ( name: . customLong( " dry-run " ) , help: " Execute command in dry run mode " )
1735+ var dryRun = false
1736+
1737+ @Option ( name: . shortAndLong, help: " Format the output (pretty|json) " )
1738+ var format : String ?
1739+
1740+ @Flag ( name: . long, help: " Shows only Compose's version number " )
1741+ var short = false
1742+
1743+ func run( ) async throws {
1744+ print ( " Mocker Compose version v0.2.0 " )
1745+ }
1746+ }
1747+
1748+ // MARK: - Compose Volumes
1749+
1750+ struct ComposeVolumes : AsyncParsableCommand {
1751+ static let configuration = CommandConfiguration (
1752+ commandName: " volumes " ,
1753+ abstract: " List volumes "
1754+ )
1755+
1756+ @OptionGroup var options : ComposeOptions
1757+
1758+ @Flag ( name: . customLong( " dry-run " ) , help: " Execute command in dry run mode " )
1759+ var dryRun = false
1760+
1761+ @Option ( name: . long, help: " Format output using a custom template " )
1762+ var format : String ?
1763+
1764+ @Flag ( name: . shortAndLong, help: " Only display volume names " )
1765+ var quiet = false
1766+
1767+ func run( ) async throws {
1768+ let ( composeFile, _) = try options. loadCompose ( )
1769+ for (name, _) in composeFile. volumes {
1770+ print ( name)
1771+ }
1772+ }
1773+ }
1774+
1775+ // MARK: - Compose Wait
1776+
1777+ struct ComposeWait : AsyncParsableCommand {
1778+ static let configuration = CommandConfiguration (
1779+ commandName: " wait " ,
1780+ abstract: " Block until containers of all (or specified) services stop "
1781+ )
1782+
1783+ @OptionGroup var options : ComposeOptions
1784+
1785+ @Flag ( name: . customLong( " down-project " ) , help: " Drops project when the first container stops " )
1786+ var downProject = false
1787+
1788+ @Flag ( name: . customLong( " dry-run " ) , help: " Execute command in dry run mode " )
1789+ var dryRun = false
1790+
1791+ @Argument ( help: " Service names " )
1792+ var services : [ String ] = [ ]
1793+
1794+ func run( ) async throws {
1795+ throw MockerError . operationFailed ( " compose wait is not yet supported with Apple Containerization " )
1796+ }
1797+ }
1798+
1799+ // MARK: - Compose Watch
1800+
1801+ struct ComposeWatch : AsyncParsableCommand {
1802+ static let configuration = CommandConfiguration (
1803+ commandName: " watch " ,
1804+ abstract: " Watch build context for service and rebuild/refresh containers when files are updated "
1805+ )
1806+
1807+ @OptionGroup var options : ComposeOptions
1808+
1809+ @Flag ( name: . customLong( " dry-run " ) , help: " Execute command in dry run mode " )
1810+ var dryRun = false
1811+
1812+ @Flag ( name: . customLong( " no-up " ) , help: " Do not build & start services before watching " )
1813+ var noUp = false
1814+
1815+ @Flag ( name: . long, help: " Prune dangling images on rebuild " )
1816+ var prune = false
1817+
1818+ @Flag ( name: . shortAndLong, help: " Hide build output " )
1819+ var quiet = false
1820+
1821+ @Argument ( help: " Service names " )
1822+ var services : [ String ] = [ ]
1823+
1824+ func run( ) async throws {
1825+ throw MockerError . operationFailed ( " compose watch is not yet supported with Apple Containerization " )
1826+ }
1827+ }
1828+
1829+ // MARK: - Compose Bridge
1830+
1831+ struct ComposeBridge : AsyncParsableCommand {
1832+ static let configuration = CommandConfiguration (
1833+ commandName: " bridge " ,
1834+ abstract: " Convert compose files into another model "
1835+ )
1836+
1837+ @OptionGroup var options : ComposeOptions
1838+
1839+ @Flag ( name: . customLong( " dry-run " ) , help: " Execute command in dry run mode " )
1840+ var dryRun = false
1841+
1842+ func run( ) async throws {
1843+ throw MockerError . operationFailed ( " compose bridge is not yet supported with Apple Containerization " )
1844+ }
1845+ }
1846+
1847+ // MARK: - Compose Publish
1848+
1849+ struct ComposePublish : AsyncParsableCommand {
1850+ static let configuration = CommandConfiguration (
1851+ commandName: " publish " ,
1852+ abstract: " Publish compose application "
1853+ )
1854+
1855+ @OptionGroup var options : ComposeOptions
1856+
1857+ @Flag ( name: . long, help: " Published compose application (includes env) " )
1858+ var app = false
1859+
1860+ @Flag ( name: . customLong( " dry-run " ) , help: " Execute command in dry run mode " )
1861+ var dryRun = false
1862+
1863+ @Option ( name: . customLong( " oci-version " ) , help: " OCI image/artifact specification version " )
1864+ var ociVersion : String ?
1865+
1866+ @Flag ( name: . customLong( " resolve-image-digests " ) , help: " Pin image tags to digests " )
1867+ var resolveImageDigests = false
1868+
1869+ @Flag ( name: . customLong( " with-env " ) , help: " Include environment variables in the published application " )
1870+ var withEnv = false
1871+
1872+ @Flag ( name: [ . customShort( " y " ) , . long] , help: " Assume \" yes \" as answer to all prompts " )
1873+ var yes = false
1874+
1875+ @Argument ( help: " Repository for the published image " )
1876+ var repository : String
1877+
1878+ func run( ) async throws {
1879+ throw MockerError . operationFailed ( " compose publish is not yet supported with Apple Containerization " )
1880+ }
1881+ }
0 commit comments