Skip to main content

Switch projects with ease.

Project description

Project archer is a program that allows easy switching between different things such as projects, servers, application servers by changing the current shell.

Installation

pip3 install project-archer

Configuration

In order to define a new type of a resource, let’s say a project, you need first to configure in your .bashrc the following:

eval "$(archer project)"

This defines a new function in the shell called project. Using this command you’re able to manage the projects, as well as changing to the current one.

i.e. on my machine:

Available projects:
 - mopyx.yml: mopyx
 - gsb.yml: Germanium Selector Builder
 ...
 - lic.yml: Germanium Licenses
 - gsr.yml: Germanium Star - Runner
Current project: <none>

In order to create a new project just run:

project -n test

This opens the currently configured editor in the $EDITOR shell variable, and in there define what happens when switching to that project. This file is created in ~/.archer/projects/test.yml

config:
  name: Some descriptive name of your project
  layouts:
  - maven
  exports:
    VAR1: value
  requires:
  - JAVA_HOME
  commands:
    command1: |
      ls -l ...
    command2: |
      # do something else
      pwd
  activate: |
    # this script runs only once after this project is selected
    ..
  deactivate: |
    # this script runs when switching to another project
    ..

Layouts have the same structure, and hold common activate, deactivate, exports and commands that are used over multiple projects. By just pointing to the layout all the scripts are being mixed into the current project definition. Having a requires enforces some environment variables to be present before switching to the other project.

Layouts have the same structure, except they reside in ~/.archer/projects/layouts/*.yml.

The variables that are exposed into the exports are exported in the current shell.

Each of the commands is wrapped into a shell function and available for execution.

Example Maven Layout

layout:
    name: maven
    requires: [ PROJECT_HOME ]
    exports:
        PROJECT_BUILD_FOLDER: target/
        MAVEN_OPTS: -Xmx2048m
    commands:
        build: |
            CURRENT_FOLDER=$(pwd)
            cd $PROJECT_HOME
            mvn install $@ $EXTRA_MAVEN_PARAMS
            cd $CURRENT_FOLDER
        clean: |
            CURRENT_FOLDER=$(pwd)
            cd $PROJECT_HOME
            mvn clean $@ $EXTRA_MAVEN_PARAMS
            cd $CURRENT_FOLDER
        test: |
            CURRENT_FOLDER=$(pwd)
            cd $PROJECT_HOME
            mvn test $@ $EXTRA_MAVEN_PARAMS
            cd $CURRENT_FOLDER
        cdproj: |
            cd $PROJECT_HOME
        rebuild: |
            clean && build $@

And a sample project let’s say called lic.yml:

config:
  name: Germanium Licenses
  layouts:
    - maven
  exports:
    PROJECT_HOME: /home/raptor/projects/germanium-license
  activate: |
    cdproj

When calling project lic, the project gets activated, our current folder gets automatically changed to /home/raptor/projects/germanium-license, and in the current shell we have now defined the commands, build, clean, test, cdproj and rebuild that execute from any folder we’re in the maven builds.

To have another maven project, means now just having another file pointing to the different PROJECT_HOME.

The commands are defined per domain of a problem, and when switching to another project, the old commands, and all associated environment variables are undefined.

This also makes sense to start combining them, for example having a server and a project definition and testing two projects against tow application servers becomes:

project A
rebuild
serverstop                              # we stop whatever tomcat my be active
server tomcat7
redeploy && serverstart                 # test on tomcat 7
serverstop                              # we stop the current tomcat
server tomcat8
redeploy && serverstart                 # test on tomcat 8
serverstop                              # we stop the current tomcat
# we go now on testing project B
project B
rebuild
server tomcat7
redeploy && serverstart                 # test on tomcat 7
serverstop                              # we stop the current tomcat
server tomcat8
redeploy && serverstart                 # test on tomcat 8

Whenever in doubt a call to either project or server shows the list of available servers, and projects, and the active server and project.

Note that everything becomes far more easier, since we don’t need to move around war files, search for running tomcats, and restarting services manually, cleaning up old things. etc.

Here’s actual layouts that I use for the tomcat-server and the maven project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

project_archer-0.3.6.tar.gz (9.9 kB view details)

Uploaded Source

File details

Details for the file project_archer-0.3.6.tar.gz.

File metadata

  • Download URL: project_archer-0.3.6.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for project_archer-0.3.6.tar.gz
Algorithm Hash digest
SHA256 9b233cedf3e0a8de6ffbe0240cf539296d54e36b2ae551fa52eb33e823965bcd
MD5 c907d549853026426b6c524265dfc099
BLAKE2b-256 2fe4f9100b3710f073a3453c40b70c3ac4b49f247b8b19c086a73fe91b04cb4e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page