mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-27 01:11:03 +00:00
14a3f51b73
Legacy behaviour is mostly retained. The most notable change in behaviour is that invoking `resin deploy` without options is now allowed (see help string how it behaves). In this commit there are also the following notable changes: - Deploy/Build are promoted to primary commands - Extracts QEMU-related code to a new file - Adds a utility file to retrieve the CLI version and its parts - Adds a helper that can be used to manipulate display on capable clients - Declares several new dependencies. Most are already indirectly installed via some dependency Change-Type: minor
66 lines
1.1 KiB
CoffeeScript
66 lines
1.1 KiB
CoffeeScript
|
|
windowSize = {}
|
|
|
|
updateWindowSize = ->
|
|
size = require('window-size').get()
|
|
windowSize.width = size.width
|
|
windowSize.height = size.height
|
|
|
|
process.stdout.on('resize', updateWindowSize)
|
|
|
|
module.exports = (stream = process.stdout) ->
|
|
# make sure we get initial metrics
|
|
updateWindowSize()
|
|
|
|
currentWindowSize = ->
|
|
# always return a copy
|
|
width: windowSize.width
|
|
height: windowSize.height
|
|
|
|
hideCursor = ->
|
|
stream.write('\u001B[?25l')
|
|
|
|
showCursor = ->
|
|
stream.write('\u001B[?25h')
|
|
|
|
cursorUp = (rows = 0) ->
|
|
stream.write("\u001B[#{rows}A")
|
|
|
|
cursorDown = (rows = 0) ->
|
|
stream.write("\u001B[#{rows}B")
|
|
|
|
cursorHidden = ->
|
|
Promise = require('bluebird')
|
|
Promise.try(hideCursor).disposer(showCursor)
|
|
|
|
write = (str) ->
|
|
stream.write(str)
|
|
|
|
writeLine = (str) ->
|
|
stream.write("#{str}\n")
|
|
|
|
clearLine = ->
|
|
stream.write('\u001B[2K\r')
|
|
|
|
replaceLine = (str) ->
|
|
clearLine()
|
|
write(str)
|
|
|
|
deleteToEnd = ->
|
|
stream.write('\u001b[0J')
|
|
|
|
return {
|
|
stream
|
|
currentWindowSize
|
|
hideCursor
|
|
showCursor
|
|
cursorHidden
|
|
cursorUp
|
|
cursorDown
|
|
write
|
|
writeLine
|
|
clearLine
|
|
replaceLine
|
|
deleteToEnd
|
|
}
|