aboutsummaryrefslogtreecommitdiff
path: root/command.go
AgeCommit message (Collapse)Author
2021-08-09all: refactoring the codeShulhan
Previously we have Command, environment, and script types to handle all functionalities. The name for Command is kind a misleading, because it contains method to copy files in local or remote and to execute script in local or remote. This refactoring break down the types into Awwan, Session, and Script. Awwan contains cache of sessions and cache of environment files. Session manage and cache SSH client and list of scripts. One session have one SSH client, but may contains more than one script. Script define the content of ".aww" file, line by line.
2021-08-01all: refactoring the commandShulhan
This changes introduce new type Awwan that will run the "local" and "play" command. This is the first changes to refactoring the code to separate between script, host, and command to make it reusable and can be run multiple times.
2021-07-21all: remove double newline on loggingShulhan
2021-07-21all: expand the environment on statement when executing local scriptShulhan
This changes replace the string ${x} or $x in the statements with the current environment variables values. For example, statement "mkdir ${HOME}/tmp" will expand the ${HOME} to the current user home directory.
2021-07-13all: use native SFTP to put and get file when possibleShulhan
Previously, the command to put and get file from remote server depends on installed scp program on the host computer. In this changes we add the SFTP client and use it as primary function to put and get file to/from remote when possible and use the scp as fallback.
2021-07-12go.mod: update to latest share moduleShulhan
This update affect SSH client initialization and method to put and get file on SSH client.
2021-04-12all: check and return an error if start index is out of rangeShulhan
2021-04-12all: use consistent log prefix on command's methodsShulhan
2021-04-12all: log error when executing script (local or play)Shulhan
2021-04-04all: do not load SSH config if command mode is "local"Shulhan
If the mode is local there is no need to parse and load the SSH config, since the command to be executed will run on local machine anyway.
2021-04-04all: prefix each output of log with new lineShulhan
This is to give better readibility on the log output.
2021-03-09all: unexport the environment typeShulhan
This type is not usable if its exported. So, let unexport them to let user focus on Command.
2021-03-08all: set base dir based on the first .ssh directory that we foundShulhan
Previously, the base directory is set on current working directory. This limit the way to execute awwan only from the directory that contains the .ssh directory. This changes set the environment BaseDir based on the first .ssh directory that we found from script path up to the "/". So, user can execute awwan script from any sub-directories.
2021-03-08all: initialize SSH client before loading the scriptShulhan
This is to allow the script to reference SSHKey, SSHUser, SSHHost, and SSHPort variables from environment.
2021-03-08all: move script path, start, and end from Environment to CommandShulhan
This is the second commit for refactoring the code. The Environment will responsible to load the awwan.env files and SSHConfig, everything else will be handled by Command.
2021-03-07all: move the "mode" field from Environment to CommandShulhan
We are gonna refactor most of the code so it will be more readable and testable.
2021-03-07all: never, ever use log.Fatal on libraryShulhan
A good library is the one that return an error when something happened, not immediately stop the program. I made a mistake and I learn from it.
2020-06-26command: change the owner of file when doing #get!Shulhan
In case the owner of file is not active user and it does not have read permission, the "#get!" command will fail when copying command from remote to local.
2020-06-26environment: set the SSH key, user, host, and portShulhan
By knowing this values, user can use it to invoke other SSH related command, for example to copy file using `scp` scp -i {{.SSHKey}} src {{.SSHUser}}@{{.SSHHost}}:{{.SSHPort}}/dst
2020-06-15command: log the put and get commands on local and remoteShulhan
2020-06-04all: add magic command "#require:"Shulhan
Magic word `#require:` will ensure that the next statement will always executed when its skipped with start number. For example, given following script with line number 1: #require: 2: echo a 3: echo b 4: #require: 5: echo c ``` executing `awwan local script.aww 3`, will always execute line number 2 `echo a`, but not line number 5 (because its before line start 3).
2020-06-04command: check for single, double, or back quote on commandShulhan
Previously, if command contains quote like, echo "a b" the script will run it as ["echo", `"a`, `b"`] which is not what we will expected and may cause some command failed to run. This changes fix the parsing of command string by detecting possible quote.
2020-05-30all: update the project links to sourcehutShulhan
* Makefile: make the default task to build the command
2020-05-19awwan: add magic word "#get!"Shulhan
Magic word `#get!` will copy file from remote server, that can be accessed only by using sudo, to your local file. Example, #get! /etc/nginx/ssl/my.crt server.crt
2020-04-29all: print message to stderr instead of stdoutShulhan
This will allow piping the actual output of executed command to stdout or file.
2020-04-29command: add force option "-f" when putting file with sudoShulhan
2020-04-27all: use .ssh/config as the source of SSH host configurationShulhan
Previously we need to define the SSH host, user, port, and private key file in the environment file. This change use the SSH config format and automatically match and find the script directory name with the Host or Match section.
2020-04-17command: fix call to log functionsShulhan
2020-04-16all: add magic command to copy file with sudoShulhan
Previously, to copy file with root we use, #put: src /tmp sudo mv /tmp /desc The new magic keywords "#put!" will handle the "sudo mv" part, so user only need to put, #put! src /desc Nice!
2020-04-15all: refactoring the environmentShulhan
This change remove the command mode "bootstrap" and replace default environment file from "env.ini" to "awwan.env".
2019-10-26awwan: the configuration management for local and cloudShulhan
awwan is command line interface to configurate and manage remote system through SSH connection.