Skip to content

3.2. System Commands API

Andrey Chaschev edited this page Jan 18, 2014 · 1 revision

Smoke tests which are run during setup perform basic FS and utilities operations. In a sample below a sample below you will find that API employs the fluent interfaces technique. All commands basically represent builders which are translated into different command depending on the underlying OS, it's version and implementation loaded - i.e. remote or local.

System messages which are received during the execution are translated into internal exceptions - PermissionsException, NoSuchFileException.

_.sys.writeString("hi from ${_.host}").toPath("file1").run()

_.sys.move('file1').to('file2').run()

_.sys.move('file2').to('file3')
    .withUser("root")
    .withPermissions("o-r,g-r")
    .sudo().run()

// will throw PermissionsException
_.sys.capture('cat file3')

_.sys.copy('file3').to('file4').sudo().withUser(user).withPermissions("o+r,g+r").run()

_.sys.link('file5').toSource('file4').run()

_.sys.mkdirs("testRootDir1")
   .withUser("root.root")
   .withPermissions("o-r,g-r")
   .sudo().run()

_.sys.mkdirs("testDir2").run()

// will throw PermissionsException
_.sys.lsQuick("testRootDir1")

// will throw NoSuchFileException
_.sys.lsQuick("noSuchDir")

// will throw PermissionsException
_.sys.lsQuick("testDir2")
Clone this wiki locally