This repository has been archived by the owner on Feb 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from dgonyeo/break-copy-in-two
copy: split --to-dir flag into separate subcommand
- Loading branch information
Showing
5 changed files
with
93 additions
and
39 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# acbuild copy-to-dir | ||
|
||
`acbuild copy-to-dir` will copy any number of files and directories from the | ||
local filesystem into the ACI. | ||
|
||
It takes at least two arguments, where all but the final argument are paths on | ||
the host system. The final argument is a parent directory inside the ACI to | ||
place the files and directories in. | ||
|
||
If the target directory doesn't exist in the ACI, it will be implicitly created | ||
(along with any necessary parent directories). | ||
|
||
The following commands would do the same thing: | ||
|
||
```bash | ||
acbuild copy-to-dir apache.conf sites-available/00-default sites-available/myblog /etc/apache2 | ||
``` | ||
|
||
```bash | ||
cp apache.conf sites-available/00-default sites-available/myblog ./.acbuild/currentaci/rootfs/etc/apache2 | ||
``` | ||
|
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,65 @@ | ||
// Copyright 2015 The appc 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 | ||
// | ||
// http://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. | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/appc/acbuild/Godeps/_workspace/src/github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
toDir bool | ||
cmdCopyToDir = &cobra.Command{ | ||
Use: "copy-to-dir PATH1_ON_HOST PATH2_ON_HOST ... PATH_IN_ACI", | ||
Short: "Copy a file or directory into a directory in an ACI", | ||
Example: "acbuild copy-to-dir build/bin/* /usr/bin", | ||
Run: runWrapper(runCopyToDir), | ||
} | ||
) | ||
|
||
func init() { | ||
cmdAcbuild.AddCommand(cmdCopyToDir) | ||
} | ||
|
||
func runCopyToDir(cmd *cobra.Command, args []string) (exit int) { | ||
if len(args) == 0 { | ||
cmd.Usage() | ||
return 1 | ||
} | ||
if len(args) < 2 { | ||
stderr("copy-to-dir: incorrect number of arguments") | ||
return 1 | ||
} | ||
|
||
if debug { | ||
logMsg := "Copying " | ||
for i := 0; i < len(args)-1; i++ { | ||
logMsg += fmt.Sprintf("%s ", args[i]) | ||
} | ||
logMsg += "to " | ||
logMsg += fmt.Sprintf("%s", args[len(args)-1]) | ||
stderr(logMsg) | ||
} | ||
|
||
err := newACBuild().CopyToDir(args[:len(args)-1], args[len(args)-1]) | ||
|
||
if err != nil { | ||
stderr("copy-to-dir: %v", err) | ||
return getErrorCode(err) | ||
} | ||
|
||
return 0 | ||
} |
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