Browse Source

Update the readme with the new use and examples of the new flags

pull/646/head
Augusto 5 years ago committed by xpetit
parent
commit
c3be6bdf4d
  1. 19
      rc/README.md
  2. 4
      rc/rc.go

19
rc/README.md

@ -6,10 +6,9 @@ This program analyses a go source file and displays in standard output the impor
- Allowed
- All functions declared inside the source file are allowed
- Slices of all types are allowed
- Array of all types are allowed
- Loops are allowed
- Relative imports are allowed
- Disallowed
- NO imports are allowed
- NO built-in functions are allowed.
@ -22,13 +21,13 @@ This program analyses a go source file and displays in standard output the impor
- `-cast` allows casting to every built-in type.
- `-no-for` prohibits the use of `for` loops in the program or function.
- `-allow-builtin` allows all builtin functions and casting to builtin types
- `-no-slices` disallows the use of all slices types
- `-no-these-slices=type1,type2`: disallows the slices of type1 and type2
- `-no-arrays` disallows the use of all array types
- `-no-these-arrays=type1,type2`: disallows the arrays of type1 and type2
- `-no-relative-imports`: disallows the use of relative imports
### Arguments:
- Flags must be passed first, before any other argument
- Flags must be passed passed first, before any other argument
- After the flags the first argument must be the file to be analysed
@ -50,19 +49,19 @@ This program analyses a go source file and displays in standard output the impor
- Ex: `../piscine`, `..`, `.`
- Disallow `for` loops
- Use the flags `-no-for`.
- Disallow all aslices types.
- Use `-no-slices`
- Disallow all array types.
- Use `-no-arrays`
- Unallow literals
- Use the flag `--no-lit="{PATTERN}"`
- Note: `"{PATTERN}"` must be a valid Regular Expression.
- ex:
```console
_$ rc -no-slices --no-lit=[b-yB-Y] main.go fmt.* github.com/01-edu/z01.PrintRune len
_$ rc -no-arrays --no-lit=[b-yB-Y] main.go fmt.* github.com/01-edu/z01.PrintRune len
```
### Example:
- To allow the import of the whole `fmt` package, `z01.PrintRune` and the built-in functions `len` for the file `main.go`
Note: The imports must be writen exactly the way they are writen inside the source code, example:
```console
@ -94,7 +93,7 @@ This program analyses a go source file and displays in standard output the impor
- Disallow the use of the slices of type `string` and `int`
```console
_$ rc -no-these-slices=string,int sourcefile.go
_$ rc -no-these-arrays=string,int sourcefile.go
```
- To allow just one type of casting

4
rc/rc.go

@ -514,8 +514,8 @@ func createChildScope(
func init() {
flag.Var(&noTheseArrays, "no-these-arrays", "Disallowes the array types passed in the flag as a list separeted by comma with out spaces\nLike so: -no-these-arrays=int,string,bool")
flag.Var(&noLit, "no-lit",
`The use of string literals matching the pattern --no-lit="{PATTERN}"`+
`passed to the program would not be allowed`,
`The use of basic literals (strings or characters) matching the pattern -no-lit="{PATTERN}"
passed to the program would not be allowed`,
)
flag.BoolVar(&noRelativeImports, "no-relative-imports", false, `Disallowes the use of relative imports`)
flag.BoolVar(&noFor, "no-for", false, `The "for" instruction is not allowed`)

Loading…
Cancel
Save