diff --git a/build/build-dir.py b/build/build-dir.py deleted file mode 100755 index 8958d63..0000000 --- a/build/build-dir.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python -"""The pick_build_dir command selects a build directory - -The pick_build_dir command scans the current directory for directories starting -with ``build`` and prompts the user to select one from the list. -""" - -from __future__ import print_function - -from argparse import ArgumentParser -from os import listdir -from os.path import curdir, isdir -from sys import stderr - -from pick import Picker - - -def main(): - """Main entry point to build-dir.py script.""" - parser = ArgumentParser() - parser.add_argument('output') - parser.add_argument('--default', action='store_true') - args = parser.parse_args() - directories = [] - for directory in listdir(curdir): - if isdir(directory) and directory.startswith('build'): - directories.append(directory) - if len(directories) == 0: - print('no build directories found', file=stderr) - exit(1) - build_dirs = sorted(directories) - if args.default: - build_dir = build_dirs[0] - else: - picker = Picker(build_dirs, 'Select a build directory:') - picker.register_custom_handler(ord(''), lambda _: exit(1)) - build_dir, _ = picker.start() - with open(args.output, 'w') as output: - output.write(build_dir) - - -if __name__ == '__main__': - try: - main() - except KeyboardInterrupt: - exit(130) diff --git a/build/build.plugin.zsh b/build/build.plugin.zsh index d029019..86e4e46 100644 --- a/build/build.plugin.zsh +++ b/build/build.plugin.zsh @@ -37,15 +37,18 @@ optional arguments: EOF return fi - error() { echo "\e[31merror:\e[0m $1"; return 1 } + error() { echo "\e[31merror:\e[0m $1" } + warning() { echo "\e[33mwarning:\e[0m $1" } local build_dir if [[ ${#*} -gt 1 ]]; then echo $usage - error "unexpected position arguments: ${*[2,${#*}]}" + error "unexpected position arguments: ${*[2,${#*}]}"; return 1 elif [[ ${#*} -eq 1 ]]; then - build_dir=${*[1]} - [[ ! -d $build_dir ]] && \ - error "directory not found: $build_dir" + if [[ ! -d ${*[1]} ]]; then + warning "directory not found: ${*[1]}" + else + build_dir=${*[1]} + fi fi # If was not set begin selection @@ -60,7 +63,7 @@ EOF # Interactively select a build directory if more than 1 found integer index=0 if [[ ${#build_dirs} -eq 0 ]]; then - error "no build directories found" + error "no build directories found"; return 1 elif [[ ${#build_dirs} -gt 1 ]]; then zmodload zsh/curses && { # Get the size of the terminal @@ -139,7 +142,7 @@ EOF # If the build variable is not defined the command could not be determined if [ -z $build ]; then - echo "\e[33mwarning:\e[0m build command detection failed: $build_dir" + warning "build command detection failed: $build_dir" # Prompt user to enter a build command vared -p 'enter comand: ' build fi