-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows for a simpler, more maintainable CLI.
- Loading branch information
1 parent
20c39ce
commit f20f100
Showing
8 changed files
with
190 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
language: rust | ||
osx_image: xcode10.2 | ||
osx_image: xcode11.3 | ||
|
||
git: | ||
submodules: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2020 The xi-editor Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import ArgumentParser | ||
import AppKit | ||
|
||
public struct Xi: ParsableCommand { | ||
@Argument(help: "Relative or absolute path to the file(s) to open. If none, opens empty editor.") | ||
var files: [String] | ||
|
||
@Flag(help: "Wait for the editor to close before finishing process.") | ||
var wait: Bool | ||
|
||
public init() {} | ||
|
||
public func run() throws { | ||
|
||
guard !files.isEmpty else { | ||
NSWorkspace.shared.launchApplication("XiEditor") | ||
return | ||
} | ||
|
||
let filePaths = try files.map { | ||
try CliHelper.resolvePath(from: $0) | ||
} | ||
|
||
for filePath in filePaths { | ||
try CliHelper.openFile(at: filePath) | ||
} | ||
|
||
if wait, !filePaths.isEmpty { | ||
print("waiting for editor to close...") | ||
let group = DispatchGroup() | ||
group.enter() | ||
CliHelper.setObserver(group: group, filePaths: filePaths) | ||
group.wait() | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.