1
// Copyright 2015 Canonical Ltd.
2
// Licensed under the LGPLv3, see LICENCE file for details.
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
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
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
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
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
37
MkdirAll(dirname string) []string
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