summary refs log tree commit diff stats
path: root/Makefile
blob: 5de061ffa31cca22f96292948e7f4d5e2335d7b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# This file is part of ranger, the console file manager.
# License: GNU GPL version 3, see the file "AUTHORS" for details.

NAME = ranger
VERSION = $(shell grep -m 1 -o '[0-9][0-9.]\+' README.md)
NAME_RIFLE = rifle
VERSION_RIFLE = $(VERSION)
SNAPSHOT_NAME ?= $(NAME)-$(VERSION)-$(shell git rev-parse HEAD | cut -b 1-8).tar.gz
# Find suitable python version (need python >= 2.6 or 3.1):
PYTHON ?= $(shell python -c 'import sys; sys.exit(sys.version < "2.6")' && \
	which python || which python3.3 || which python3.2 || which python3.1 || \
	which python3 || which python2.7 || which python2.6)
SETUPOPTS ?= '--record=install_log.txt'
DOCDIR ?= doc/pydoc
DESTDIR ?= /
PYOPTIMIZE ?= 1
FILTER ?= .

CWD = $(shell pwd)

default: test compile
	@echo 'Run `make options` for a list of all options'

options: help
	@echo
	@echo 'Options:'
	@echo 'PYTHON = $(PYTHON)'
	@echo 'PYOPTIMIZE = $(PYOPTIMIZE)'
	@echo 'DOCDIR = $(DOCDIR)'
	@echo 'DESTDIR = $(DESTDIR)'

help:
	@echo 'make:          Test and compile ranger.'
	@echo 'make install:  Install $(NAME)'
	@echo 'make clean:    Remove the compiled files (*.pyc, *.pyo)'
	@echo 'make doc:      Create the pydoc documentation'
	@echo 'make cleandoc: Remove the pydoc documentation'
	@echo 'make man:      Compile the manpage with "pod2man"'
	@echo 'make manhtml:  Compile the html manpage with "pod2html"'
	@echo 'make snapshot: Create a tar.gz of the current git revision'
	@echo 'make test:     Test all testable modules of ranger'
	@echo 'make todo:     Look for TODO and XXX markers in the source code'

install:
	$(PYTHON) setup.py install $(SETUPOPTS) \
		'--root=$(DESTDIR)' --optimize=$(PYOPTIMIZE)

compile: clean
	PYTHONOPTIMIZE=$(PYOPTIMIZE) $(PYTHON) -m compileall -q ranger

clean:
	find ranger -regex .\*\.py[co]\$$ -delete
	find ranger -depth -name __pycache__ -type d -exec rm -rf -- {} \;

doc: cleandoc
	mkdir -p $(DOCDIR)
	cd $(DOCDIR); \
		$(PYTHON) -c 'import pydoc, sys; \
		sys.path[0] = "$(CWD)"; \
		pydoc.writedocs("$(CWD)")'
	find . -name \*.html -exec sed -i 's|'"$(CWD)"'|../..|g' -- {} \;

test:
	@echo "Running doctests..."
	@for FILE in $(shell grep -IHm 1 doctest -r ranger | grep $(FILTER) | cut -d: -f1); do \
		echo "Testing $$FILE..."; \
		RANGER_DOCTEST=1 PYTHONPATH=".:"$$PYTHONPATH ${PYTHON} $$FILE; \
	done
	@if type -t py.test > /dev/null; then \
		echo "Running py.test tests..."; \
		py.test tests; \
	else \
		echo "WARNING: Couldn't run some tests because py.test is not installed!"; \
	fi
	@echo "Finished testing."

man:
	pod2man --stderr --center='ranger manual' --date='$(NAME)-$(VERSION)' \
		--release=$(shell date +%x) doc/ranger.pod doc/ranger.1
	pod2man --stderr --center='rifle manual' --date='$(NAME_RIFLE)-$(VERSION_RIFLE)' \
		--release=$(shell date +%x) doc/rifle.pod doc/rifle.1

manhtml:
	pod2html doc/ranger.pod --outfile=doc/ranger.1.html

cleandoc:
	test -d $(DOCDIR) && rm -f -- $(DOCDIR)/*.html || true

snapshot:
	git archive --prefix='$(NAME)-$(VERSION)/' --format=tar HEAD | gzip > $(SNAPSHOT_NAME)

dist: snapshot

todo:
	@grep --color -Ion '\(TODO\|XXX\).*' -r ranger

.PHONY: clean cleandoc compile default dist doc help install man manhtml options snapshot test todo
">ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "RIFLE 1" .TH RIFLE 1 "rifle-1.6.1" "04/10/2015" "rifle manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" rifle \- ranger's file opener .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBrifle\fR [\fB\-\-help\fR] [\fB\-f\fR \fI\s-1FLAGS\s0\fR] [\fB\-l\fR] [\fB\-p\fR \fI\s-1KEYWORD\s0\fR] [\fB\-w\fR \fI\s-1PROGRAM\s0\fR] \fIfiles\fR .SH "DESCRIPTION" .IX Header "DESCRIPTION" rifle is a powerful file executor that allows for complex file type checking, written to meet the needs of the file manager \fIranger\fR. rifle's strength lies in automatically determining file types, depending on which programs are installed on the system, even without any user interaction. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-f\fR \fI\s-1FLAGS\s0\fR" 14 .IX Item "-f FLAGS" Specify flags for opening the files. Flags are letters that changes how the program is executed. Any combination of flags will work. Writing uppercase flags will negate the effect of all previously used lowercase flags of the same letter. .Sp Table of all flags: f fork program to background r run program as root, using sudo t run program in a separate terminal, as specified by \f(CW$TERMCMD\fR .IP "\fB\-l\fR" 14 .IX Item "-l" List all possible ways to open the specified files. Each line will contain information in the format of \fIid:label:flags:command\fR. \fIid\fR is the identification number. \fIlabel\fR is an arbitrary string that was specified for this command, \fIflags\fR are the flags that are used by default, and \fIcommand\fR is the command that is going to be executed. .IP "\fB\-p\fR \fI\s-1KEYWORD\s0\fR" 14 .IX Item "-p KEYWORD" Pick a method to open the files. .Sp \&\fI\s-1KEYWORD\s0\fR is either the \s-1ID\s0 number listed by \f(CW\*(C`rifle \-l\*(C'\fR or a string that matches a label in the configuration file. .IP "\fB\-w\fR \fI\s-1PROGRAM\s0\fR" 14 .IX Item "-w PROGRAM" Open the files with the program \fI\s-1PROGRAM\s0\fR .IP "\fB\-h\fR, \fB\-\-help\fR" 14 .IX Item "-h, --help" Print a list of options and exit. .SH "FILES" .IX Header "FILES" rifle shares configuration files with ranger, though ranger is not required in order to use rifle. The configuration file \fIrifle.conf\fR is expected to be at \&\fI~/.config/ranger/rifle.conf\fR. .PP This file specifies patterns for determining the commands to open files with. The syntax is described in the comments of the default \fIrifle.conf\fR that ships with ranger. To obtain it, you need to run: \f(CW\*(C`ranger \-\-copy\-config=rifle\*(C'\fR .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" .IP "\s-1EDITOR\s0" 8 .IX Item "EDITOR" Determines which editor to use for editing files (in the default \fIrifle.conf\fR). .IP "\s-1PAGER\s0" 8 .IX Item "PAGER" Determines which pager to use for displaying files (in the default \fIrifle.conf\fR). .IP "\s-1TERMCMD\s0" 8 .IX Item "TERMCMD" Determines the terminal emulator command for use with the \fIt\fR flag. It is required that the value is the path to an executable file which accepts the \*(L"\-e \s-1COMMAND\*(R"\s0 argument. .IP "\s-1XDG_CONFIG_HOME\s0" 8 .IX Item "XDG_CONFIG_HOME" Specifies the directory for configuration files. Defaults to \fI\f(CI$HOME\fI/.config\fR. .SH "EXAMPLES" .IX Header "EXAMPLES" List all the different methods: .PP .Vb 4 \& $ rifle \-l helloworld.py \& 0:editor::"$EDITOR" \-\- "$@" \& 1:pager::"$PAGER" \-\- "$@" \& 2:::python \-\- "$1" .Ve .PP Display its content by opening it with \*(L"cat\*(R": .PP .Vb 2 \& $ rifle \-w cat helloworld.py \& print("Hello World!") .Ve .PP Run it by picking the method 2, which calls 'python \*(-- \*(L"$1\*(R"': .PP .Vb 2 \& $ rifle \-p 2 helloworld.py \& Hello World! .Ve .PP Display the file in a pager inside a new terminal, run as root: .PP .Vb 1 \& $ rifle \-p 1 \-f tr helloworld.py .Ve