Skip to content

Commit

Permalink
Merge pull request #34 from cs50/develop
Browse files Browse the repository at this point in the history
v2.1.5
  • Loading branch information
Kareem Zidane authored Sep 18, 2017
2 parents c54867d + b336a98 commit 44a4f32
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ This is style50, a tool with which code can be checked against the CS50 style gu

pip install style50

In order to style check C, C++, or Java code, a recent version (`>=3.0.1`) of `astyle` must be installed. `astlye` may be downloaded [here](https://sourceforge.net/projects/astyle/files/astyle/astyle%203.0.1/).
In order to style check C, C++, or Java code, a recent version (`>=3.0.1`) of `astyle` must be installed. `astyle` may be downloaded [here](https://sourceforge.net/projects/astyle/files/astyle/astyle%203.0.1/).

### Windows
Along with most of CS50's command line tools, `style50` supports being run on Windows but only via the [Linux Subsystem in Windows 10](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide). After launching it, `style50` can be installed using the `pip` command above.

## Usage

```
usage: style50 [-h] [-o MODE] [-v] [-V] file [file ...]
usage: style50 [-h] [-o MODE] [-v] [-V] [-E] FILE [FILE ...]
positional arguments:
file file or directory to lint
FILE file or directory to lint
optional arguments:
-h, --help show this help message and exit
Expand All @@ -22,6 +25,8 @@ optional arguments:
unified, score, or json
-v, --verbose print full tracebacks of errors
-V, --version show program's version number and exit
-E, --extensions print supported file extensions (as JSON list) and
exit
```

`character`, `split`, and `unified` modes output character-based, side-by-side, and unified (respectively) diffs between the inputted file and the correctly styled version. `score` outputs the raw percentage of correct (unchanged) lines, while `json` outputs a json object containing information pertinent to the CS50 IDE plugin (coming soon).
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"Topic :: Utilities"
],
description="This is style50, with which code can be checked against the CS50 style guide",
install_requires=["argparse", "autopep8", "icdiff", "jsbeautifier", "six", "termcolor"],
install_requires=["argparse", "autopep8", "icdiff", "jsbeautifier==1.6.14", "six", "termcolor"],
dependency_links=["git+https://github.com/jeffkaufman/icdiff.git"],
keywords=["style", "style50"],
name="style50",
Expand All @@ -20,5 +20,5 @@
"console_scripts": ["style50=style50.__main__:main"],
},
url="https://github.com/cs50/style50",
version="2.1.4"
version="2.1.5"
)
8 changes: 6 additions & 2 deletions style50/__main__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import print_function
from __future__ import division

import argparse
import json
import signal
import sys
import traceback

import argparse
import termcolor

from . import Style50, Error, __version__
Expand Down Expand Up @@ -48,13 +49,16 @@ def main():

# Define command-line arguments.
parser = argparse.ArgumentParser(prog="style50")
parser.add_argument("file", nargs="+", help="file or directory to lint")
parser.add_argument("FILE", nargs="+", help="file or directory to lint")
parser.add_argument("-o", "--output", action="store", default="character",
choices=["character", "split", "unified", "score", "json"], metavar="MODE",
help="output mode, which can be character (default), split, unified, score, or json")
parser.add_argument("-v", "--verbose", action="store_true",
help="print full tracebacks of errors")
parser.add_argument("-V", "--version", action="version", version=__version__)
parser.add_argument("-E", "--extensions", action="version",
version=json.dumps(list(Style50.extension_map.keys())),
help="print supported file extensions (as JSON list) and exit")

main.args = parser.parse_args()
Style50(main.args.file, output=main.args.output).run()
Expand Down

0 comments on commit 44a4f32

Please sign in to comment.