~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/utils/shell/command.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2015 Canonical Ltd.
 
2
// Licensed under the LGPLv3, see LICENCE file for details.
 
3
 
 
4
package shell
 
5
 
 
6
import (
 
7
        "os"
 
8
        "time"
 
9
)
 
10
 
 
11
// CommandRenderer provides methods that may be used to generate shell
 
12
// commands for a variety of shell and filesystem operations.
 
13
type CommandRenderer interface {
 
14
        // Chown returns a shell command for changing the ownership of
 
15
        // a file or directory. The copies the behavior of os.Chown,
 
16
        // though it also supports names in addition to ints.
 
17
        Chown(name, user, group string) []string
 
18
 
 
19
        // Chmod returns a shell command that sets the given file's
 
20
        // permissions. The result is equivalent to os.Chmod.
 
21
        Chmod(path string, perm os.FileMode) []string
 
22
 
 
23
        // WriteFile returns a shell command that writes the provided
 
24
        // content to a file. The command is functionally equivalent to
 
25
        // ioutil.WriteFile with permissions from the current umask.
 
26
        WriteFile(filename string, data []byte) []string
 
27
 
 
28
        // Mkdir returns a shell command for creating a directory. The
 
29
        // command is functionally equivalent to os.MkDir using permissions
 
30
        // appropriate for a directory.
 
31
        Mkdir(dirname string) []string
 
32
 
 
33
        // MkdirAll returns a shell command for creating a directory and
 
34
        // all missing parent directories. The command is functionally
 
35
        // equivalent to os.MkDirAll using permissions appropriate for
 
36
        // a directory.
 
37
        MkdirAll(dirname string) []string
 
38
 
 
39
        // Touch returns a shell command that updates the atime and ctime
 
40
        // of the named file. If the provided timestamp is nil then the
 
41
        // current time is used. If the file does not exist then it is
 
42
        // created. If UTC is desired then Time.UTC() should be called
 
43
        // before calling Touch.
 
44
        Touch(filename string, timestamp *time.Time) []string
 
45
}